Plotting Matrices Stored in Sequential Array Cells

조회 수: 3 (최근 30일)
Stephen
Stephen 2012년 12월 20일
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에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by