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

A quick question regarding matlab

  1. Oct 3, 2011 #1
    Hello

    Well since i'm a beginner in Matlab i have a question aboute ploting the graph. How can I merge two graphs into one ? Since i have function test(x,h) and function test2(x,h) both of them plotts in a two separate graphs. How do i do if i want to see both of them in a single graph ?

    Regards

    Carl F
     
  2. jcsd
  3. Oct 3, 2011 #2

    uart

    User Avatar
    Science Advisor

    One way is to make your functions return a vector rather than just plotting it. Then it would be something like:

    y1 = test1(x,h)
    y2 = test2(x,h)
    plot(x,y1,x,y2)
     
  4. Oct 3, 2011 #3

    marcusl

    User Avatar
    Science Advisor
    Gold Member

    This will also plot them on one graph:

    plot(x,y1)
    hold on
    plot(x,y2)
    hold off
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: A quick question regarding matlab
  1. Quick MATLAB Question (Replies: 1)

  2. Quick matlab question (Replies: 5)

  3. Matlab quick question (Replies: 1)

Loading...