I'm trying to update new values to a function using the 'set' function.
Here is the code:
daq_object = analoginput('winsound');
chan = addchannel(daq_object,1);
x=[10];开发者_如何学运维
num_samples = 1000;
axes(handles.axes1);
plot_handle=surf(T,F,10*log10(P),'edgecolor','none');
axis tight;
view(0,90);
xlabel('Time (Seconds)'); ylabel('Hz');
set(daq_object,'SamplesPerTrigger',inf,'SamplesAcquiredFcnCount',num_samples,...
'SamplesAcquiredFcn',{@update_plot,handles});
function update_plot(handles)
data = getdata(daq_object,num_samples);
[S,F,T,P] = spectrogram(data,256,250,256,1E3);
set(plot_handle,'YData',T,F,P); % ERROR WITH THIS, UPDATING THE VARIABLES.
end
The error is that, I don't know how to update multiple variables in a function. for one variable ex:
h=plot(zeros(100,2));
for i=1:20
set(h,'Ydata',rand(10,1));
drawnow;
end
but here I need to update the T,F and P values. How can I use SET to do that?
I tried:
set(plot_handle,'YData',T,F,P);
but thats just giving me errors.
set
takes name-value pairs, that is, after the first variable (which is a handle to a figure or some axes), the arguments need to alternate name of variable
, then value to assign to that variable
.
In your example that failed you have three consecutive values (T
, F
and P
) without names in between.
精彩评论