Plotting Matrices Stored in Sequential Array Cells
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hey,
I've got an array which has a few matrices stored in the arrays and now I'm wanting to plot them. Now I can see two ways of doing this, I can do it a long winded way of stating the plot code over and over for the different cell numbers or I can use a for loop with a plot code inside which then cycles through the cells. (See example code below). I don't like either of these methods.
Is there a nicer way of achieving this that anyone can think of?
If any more details are required feel free to ask!
A very crude example of what I'm doing is;
x1 = 1:10;
y1 = 1:10;
x2 = 1:20;
y2 = [1:20].^2;
plotter{1} = {x1 y1};
plotter{2} = {x2 y2};
figure(1)
plot(plotter{1}{1},plotter{1}{2})
figure(2)
plot(plotter{2}{1},plotter{2}{2})
for n = 1:2
figure(2+n)
plot(plotter{n}{1},plotter{n}{2})
end
0 commentaires
Réponse acceptée
Walter Roberson
le 20 Déc 2012
Provided that the plotter elements all occur in horizontal pairs, odd numbered elements being x arrays and even numbered elements being y arrays, then
T = [plotter{:}];
plot(T{:});
This does not require that the plotter{K} be exactly the same length -- plotter{1} could be 6 elements long, plotter{2} could be 2 elements long. As long as the horizontal sequence alternates x and y.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Axis Labels dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!