フィルターのクリア

Plotting Matrices Stored in Sequential Array Cells

2 ビュー (過去 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 Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by