MATLAB: Set Ydata in Matlab, how does it work

MATLABplotset

Hello, i came across this code.
plot_handle=plot(zeros(num_samples,2));
then in another function which is called update the plot.
i saw this.
data = getdata(daq_object,num_samples);
for i = 1:length(plot_handle)
set(plot_handle(i),'YData',data(:,i));
end
I don't get how the set(plot_handle(i),'YData',data(:,i)); works, beacuse in the plot_handle function, i only have num_samples as input.

Best Answer

I think it's a real time update (since it ivolves a daq object) of your plot.
A general example is:
h = plot(rand(10,1))
for n = 1:20
set(h,'Ydata',rand(10,1))
pause(.1)
end