sine wave in matlab

Discussion in 'Programmer's Corner' started by Ron Potashnik, Mar 21, 2016.

  1. Ron Potashnik

    Thread Starter New Member

    Dec 27, 2015
    15
    0
    hello.
    i wrote this code in matlab

    t=[0:0.2e-3:3e-3];
    f=2*pi;
    v=sin(f*t*1000);
    plot(t,v)

    and my sine plot is looking like this
    matlab.png

    why dosent it look like a normal sine wave
     
  2. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    How many samples are you generating each cycle?
     
  3. Ron Potashnik

    Thread Starter New Member

    Dec 27, 2015
    15
    0
    i fix my problem with more samples. tnx
     
  4. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Good.

    A good rule of thumb is that you need at least about ten samples per cycle for it to look halfway decent for humans -- more is better. But, from a sampling theorem and information theory standpoint you can get by with less.
     
Loading...