Trouble plotting a simple sin function

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
Lolsauce
Messages
21
Reaction score
0
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:
>> 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:
>> 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?
 
Physics news on Phys.org
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.