How to plot each matrix in a cell?

6 views (last 30 days)
Viet Duc
Viet Duc on 16 Sep 2013
Hi everyone
I have a cell with size of 1x650 cell
And the size each matrix in the cell is 1x1300 double like this
A{n} = [1x1300 double] [1x1300 double] .... [1x1300 double]
Each matrix in the cell I have a graph
I want to plot all matrix in the cell into a figure
So how to plot the cell like this?

Accepted Answer

Simon
Simon on 16 Sep 2013
Hi!
Create a figure, set it to "hold" (i.e. overwriting with subsequent plots) and plot
figure(1); cla; hold on;
cellfun(@(x) plot(x), A)
  3 Comments
Simon
Simon on 16 Sep 2013
figure(1); cla; hold on;
h = cellfun(@(x) plot(x), A);
This gives you the handle of each plot, in your case a vector of 650 handles. "h(100)" corresponds to "A{100}" and so on.
Knowing the handle you may change almost everything in the figure
% change color
set(h(100), 'Color', 'k')
% get values of plot
get(h(100), 'YData')
For further reading: http://www.mathworks.com/help/matlab/plot-objects-1.html, look at "Lineseries Properties"
Viet Duc
Viet Duc on 16 Sep 2013
Thank you very much
I got it.... :)

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!