フィルターのクリア

Retrieveing and replacing data in a plot

40 ビュー (過去 30 日間)
Rosie
Rosie 2012 年 8 月 10 日
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

採用された回答

Matt Fig
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 件のコメント
Rosie
Rosie 2012 年 8 月 14 日
Thanks so much, Matt.
Turns out the only thing missing were the curly brackets around 'YData' - amateur mistake =\
Thanks again

サインインしてコメントする。

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 8 月 10 日
maby you should convert your data from cell to mat
ydata=cell2mat(ydata)
  1 件のコメント
Rosie
Rosie 2012 年 8 月 13 日
Thanks for the quick response.
I tried this before. Unfortunately it seems to want only a single vector of ydata. What bothers me is that I recieved it in 2 cells of data, so why can't I put it back in the form of 2 cells of data?
Or is there some way I can trick it into putting it back?

サインインしてコメントする。

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by