MATLAB - creating a plot

Discussion in 'Programmer's Corner' started by shespuzzling, Feb 5, 2011.

  1. shespuzzling

    Thread Starter Active Member

    Aug 13, 2009
    88
    0
    Hi,

    I need to create a plot in matlab and I don't have any experience with the program. The plot we're supposed to create looks like a stepped sine wave with 6 distinct intervals (i.e. y=50 for the first interval, then 90, then 50, then -30, then -70, then -30 and 0).

    We're sampling this at a particular frequency so I created the vector for the x axis but I can't figure out how to do it for the y axis. I tried using the for command, but I don't think I'm doing that right. If anybody can help me I'd appreciate it.

    Thanks.
     
  2. jut

    Senior Member

    Aug 25, 2007
    224
    2
    Provide a sketch for desired plot. Also provide the code you've tried in matlab so I can help you better.
     
  3. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    Here is an example:

    Tsample=0.1
    ts=0:Tsample:2;

    As=sin(2*pi*ts);

    figure(1)
    stairs(ts,As)
     
Loading...