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!

Homework Help: Plotting Multiple Equations on One Graph in MATLAB?

  1. Oct 2, 2012 #1
    1. The problem statement, all variables and given/known data

    Does anyone know how to do this? Let's say I had the equation:

    f(t) =
    |2t, 0≤ t < 2
    |(t^2)-3, 2≤t

    how would you plot this over 0≤ t ≤4 in Matlab?

    2. Relevant equations


    3. The attempt at a solution

    I've tried ezplot but i can't manage getting both equations on the same graph

    Thanks guys and girls.

  2. jcsd
  3. Oct 2, 2012 #2
    worked it out!

    if anyone is interested the code is below

    syms x y
    ezplot(function, [xmin,xmax])
    hold on
    ezplot(function2, [xmin,xmax])
    hold off
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook