MATLAB Answers

M.A.
0

How can i plot f(i),g(i),h(i) in one figure(i)?

Asked by M.A.
on 7 Jun 2014
Latest activity Commented on by Star Strider
on 7 Jun 2014

I want to plot each three diagrams in one figure

  0 Comments

Log in to comment.

1 Answer

Answer by Star Strider
on 7 Jun 2014
 Accepted answer

Use the subplot function.

Your loop becomes:

figure(1)
for i = 1:3
    subplot(3,1,i)
       . . .
    plot(x,f(i),'-b', ... )
       . . .
end

to get 3 stacked plots in one figure. Other configurations are possible. See the documentation on subplot for details.

  6 Comments

I edited the code in my previous comment rather than re-post different code here. It should now do what you want.

The plots look strange because you have ‘axis equal’ in your plot statements. I left that in because it was in your original code. (I took it out when I ran it to be sure everything was plotting correctly.)

thank you so much

Log in to comment.


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

MATLAB Academy

New to MATLAB?

Learn MATLAB today!