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

Trouble plotting a simple sin function

  1. Sep 18, 2011 #1
    So all I'm trying to do is plot y = (2sin(3w))/w, w is the angular frequency. I basically want this graph in radians. So this is what I did at first:

    Code (Text):
    >> x = [0:.01:20] ;    //want bounds from 0 to 20
    y = 2.*((sin(3.*x))/x);
    plot(y)
    But when I do this I get a graph of nothing, I assumed it was in radians by default. Next I tried this

    Code (Text):
    >> x = [0:.01:20] ;    //want bounds from 0 to 20
    y = 2.*((sin(3.*(2.*pi)/x))/x);
    plot(y)
    I knew angular frequency is 2pi/T, so I tried converting the values of x to radians, but it didn't work either. Any tips?
     
  2. jcsd
  3. Sep 18, 2011 #2
    Your y is only 1 value at the end change your ))/x to ))./x and your graph comes out correctly.

    Also you might want to change your starting index from 0 to 0.01, since you get y(1) = NaN. The plot still comes out correctly but if you're doing anything else with y you will run into problems.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Trouble plotting a simple sin function
Loading...