Plotting Matrices Stored in Sequential Array Cells

1 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2012-12-20
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 个)

类别

Help CenterFile Exchange 中查找有关 2-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