MATLAB: A Line to plot by using handles

childrenhandlesplot

Hey Guys,
Monday Morning Question: I have got an array(1×40) holding new y-Data. Now I want to plot this data in an existing Plot. Of course i could use gca / get(…,'children') / x = get(children,'xdata') to replot, but is there anyway to add the new Data and replot by using the childrens handles ?

Best Answer

Of course i could use gca / get(...,'children') / x = get(children,'xdata') to replot, but is there anyway to add the new Data and replot by using the childrens handles ?
The get(...,'children') gives you the children's handles. If you haven't saved them when creating the plots, you'll need to get them this way. However, you can set the new y values by set(handle,'ydata',y).
No need to say that the dimensions must remain.