Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

For Loop through a Plot

Asked by Amanda on 9 May 2013

I have the following data:

A1 = [1 2;3 4]
A2 = [3 4; 5 6]
A3 = [7 4; 3 2]

I want to plot A(n) through a for loop for 3 different generation plots. Something similar to this:

for i = 1:3
plot(A(i))
end

Thanks,

Amanda

0 Comments

Amanda

Tags

Products

No products are associated with this question.

1 Answer

Answer by the cyclist on 9 May 2013
Edited by the cyclist on 9 May 2013
Accepted answer

Use cell arrays:

A{1} = [1 2;3 4]
A{2} = [3 4; 5 6]
A{3} = [7 4; 3 2]
for i = 1:3
figure
plot(A{i})
end

It wasn't perfectly clear how you wanted this plotted. I did three separately figures for the three plots.

0 Comments

the cyclist

Contact us