MATLAB: Update plot using set() with xData and yData

set

Hello,
Im trying to set a plot handle by updating its xData and ydata.I have a 2048X8 array of doubles called normWanted = 2048X8 of double type.
Ive tried:
set(hPlot3, 'Xdata',1:2048,'Ydata',normWanted);
I get the error"Value must be a vector of numeric type"
Now if I try: set(hPlot3, 'Xdata',1:2048,'Ydata',normWanted(:,1)); <- this works but only plots 1,would like to plot all 8 arrays
Any ideas on how to plot this using set or a better way,I have a figure with multiple subplots so?

Best Answer

When you plot multiple lines in a single plol, your handle is an array of line objects, one for each line. If you want to use the XData and YData properties, you must first create a line object for each data set you want to display. Then you would have to update the XData and YData properties of each line one at a time.
hPlot3 = plot(hAxes3, nan,nan, nan,nan, nan,nan, nan,nan, nan,nan, nan,nan, nan,nan, nan,nan);
set(hPlot3(1),'XData',1:2048,'YData',normWanted(:,1))
set(hPlot3(2),'XData',1:2048,'YData',normWanted(:,2))
...
set(hPlot3(8),'XData',1:2048,'YData',normWanted(:,8))