MATLAB Answers


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

Asked by MA
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


Log in to comment.

1 Answer

Answer by Star Strider
on 7 Jun 2014
 Accepted Answer

Use the subplot function.

Your loop becomes:

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

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


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 what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today