Azzera filtri
Azzera filtri

Retrieveing and replacing data in a plot

40 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Matt Fig
Matt Fig il 10 Ago 2012
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 Commento
Rosie
Rosie il 14 Ago 2012
Thanks so much, Matt.
Turns out the only thing missing were the curly brackets around 'YData' - amateur mistake =\
Thanks again

Accedi per commentare.

Più risposte (1)

Azzi Abdelmalek
Azzi Abdelmalek il 10 Ago 2012
maby you should convert your data from cell to mat
ydata=cell2mat(ydata)
  1 Commento
Rosie
Rosie il 13 Ago 2012
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?

Accedi per commentare.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by