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

Drawing a graph with matlab.

  1. Feb 2, 2008 #1


    User Avatar
    Gold Member

    I need to draw two graphs in the same axis in matlab, and I'm novice in matlab, so if someone can type the code for this it will be much appreciated, this is the only way I can learn right now.
    the graphs are of:
    [tex]\frac{1}{2}m\omega^2A^2e^{-\gamma t}[1+\frac{\gamma}{2\omega}sin(2(\omega t+\phi)+\frac{\gamma^2}{2\omega}cos^2(\omega t+ \phi)][/tex]
    and [tex]\frac{1}{2}m\omega^2A^2e^{-\gamma t}[/tex]
    where A,m and gamma are arbitrary parameters, and [tex]\omega_0/\gamma=10[/tex]
    and [tex]\omega=\sqrt{\omega_0^2-1/4\gamma^2}[/tex]
    I need that the graph will span over a number of periods.

    As I said I'm novice and not sure how to handle this, and reading the help may take more time for me.

    thanks in advance.
  2. jcsd
  3. Feb 2, 2008 #2

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    Set your time vector to be t=linspace(0,6*pi,200) which will give you a vector of 200 points evenly spaced between 0 and [itex] 6 \pi [/itex]. We can adjust this later if you wish.

    Write a function file with the outputs as your two funcitons above. To plot them on th esame axis, the command is plot(t, func1, t, func2); which will give you two lines.

    if you don't get it, I wrote a couple of lines of code to help.
    Last edited: Feb 2, 2008
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Drawing a graph with matlab.
  1. Matlab graph (Replies: 14)