Retrieveing and replacing data in a plot
34 次查看(过去 30 天)
显示 更早的评论
Hi Everyone,
I've created a GUI which plots multiple sets of data [x column of data is constant whilst there are multiple y columns of data]. Once the figure is open, a button appears which allows the user to filter the data [using butter and filtfilt]. As I've programmed it to filter again by a certain factor with every click, it's important that the process can occur more than once.
As this is part of a very complicated GUI, I don't want to overwrite the original plot by using another plot() function. What I would ideally like to do is after I have retrieved the data using
YData = get(gcf,'YData')
and changed it, I'd like to replace it by saying
set(gcf,'YData',YData)
This works fine when I have only one set of YData on the graph, but is there a way I can implement this with multiple vectors? Every time I attempt this I recieve the anticipated error that it cannot plot from cell array as there are multiple columns of y-axis data.
Thanks,
Rosie
0 个评论
采纳的回答
Matt Fig
2012-8-10
I'm a little confused. There is no ydata property for figures. Did you mask the GCF function with the line object's handles?
Any way, try this:
% First plot the data:
x = 1:10;
L = plot(x,x.^2,x,x.^2.2); % Return handles to lines.
pause; % Look at the plot, the press return...
ydata = get(L,'ydata');
ydata{1} = sqrt(ydata{1}); % Alter the first cell.
set(L,{'ydata'},ydata) % Reset the data.
更多回答(1 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!