Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Multiplot in matlab

  1. Sep 24, 2011 #1
    Dear Fellows,

    I need to plot a graph in matlab, and stuck in obtaining multi plot from it for different constant values... following example will explain my situation.


    x=1;
    y=3;
    c=x^2+4y+9z
    z=linspace(0,1.2);
    plot(z,c,'r')
    in this I want to plot for y=3,y=4,y=5 and y=0 all curves in one graph.
     
  2. jcsd
  3. Sep 24, 2011 #2

    jhae2.718

    User Avatar
    Gold Member

    Use the "hold on;" command and multiple plot statements.
     
  4. Sep 26, 2011 #3
    For different plot I need to past the whole program and change the only variable(y) and
    plot(x,y,'r')
    hold on
    plot(x,y1,'r--')
    hold on
    plot(x,y2,'b')
    Is this what you are saying?

    can you please give small example so that I can understand clearly...
     
  5. Sep 26, 2011 #4
    small example,

    x = 0:0.1:10;
    y1 = x^2 + 2x + 1;
    y2 = x^2 + 4x + 1;

    so you have two curves, y1 and y2.

    plot(x,y1,'r');
    hold on
    plot(x,y2,'b');

    this will plot y2 on the same axis as y1. you only need to type hold on once; after you type it, all further curves are put on the same plot.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Multiplot in matlab
  1. & vs. && for MATLAB (Replies: 2)

  2. Matlab concatenation (Replies: 2)

  3. Matlab and physics (Replies: 3)

  4. MATLAB problem (Replies: 1)

  5. MATLAB histogram (Replies: 3)

Loading...