Walter Roberson <firstname.lastname@example.org> wrote in message <email@example.com>... > On 10-11-30 02:05 PM, Markus Due Jakobsen wrote: > > > Thanks a lot for your reply, this was very helpful. > > However, the refreshdata method doesn’t seem to work with > > multiline plots. > > > > %% Example: > > y = rand(100,3); h = plot(y); set(h,'YDataSource','y'); > > pause(1) > > y=y(1:10,:); > > refreshdata(h); > >>> ??? Error using ==> refreshdata at 58 > >>> Could not refresh YData from 'y'. > > > > How can this be and is there a way to work around it? > > When you change the number of columns, you are changing the number of lines > plotted; I am not surprised that this gives problems. For example if the > number of lines to be plotted increases, there would have to be variables or > settings to control the line style and color of the line, and then people > would want legends to be automatically updated to reflect the new number of > lines as well... > > I suggest trying again but keeping the number of columns the same in y. If > need be, set the extra columns to NaN. > > You might also be interested in the linkdata() function, which effectively > does refreshdata() automatically twice a second.
But an error message is thrown without changing the column size; In this example I simply refreshdata without changing the data and an error is thrown.
X = 1:100; Y = repmat(X,3,1); h = plot(X,Y); set(h,'YDataSource','Y'); set(h,'XDataSource','X') refreshdata(h); ??? Error using ==> refreshdata at 58 Could not refresh YData from 'Y'.