1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Graphs in matlab

  1. Nov 2, 2009 #1
    1. The problem statement, all variables and given/known data

    If we have a function f with respect to t,
    given:
    h=a/n
    t=i*h

    so this means, t depends on n.
    I have a function in matlab named num.m: where n is the only input and. My question is: if i num(10) i can generate a graph of t (x axis) against f (y axis) by the command: plot(t,f). and i can also generate a graph for n=80 by executing num(80)

    but...how can i have them on the same graph?
    i tried to plot them on the same graph, but i get an error: vectors must be of the same length.

    2. Relevant equations



    3. The attempt at a solution

    Thanks in advance.
     
  2. jcsd
  3. Nov 2, 2009 #2

    Mark44

    Staff: Mentor

    To get more than one equation on your graph, see Ch 3 in this tutorial, http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/getstart.pdf, especially p. 3-33, Adding More Data to the Graph.

    From the error you're getting, your arrays are apparently different sized, meaning they have different numbers of elements in them. If you want to graph, say x vs. t and y vs. t, make sure that all three arrays have 80 (or however many) elements in them.
     
  4. Nov 2, 2009 #3
    thanks. i used it and it helped a lot.
    :)
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Graphs in matlab
  1. Matlab 3d graph (Replies: 1)

  2. Graphs in matlab (Replies: 9)

Loading...