Trouble plotting a simple sin function

In summary, the conversation discusses plotting the function y = (2sin(3w))/w in radians. The first attempt at plotting using the given bounds of 0 to 20 resulted in an empty graph, leading to the assumption that the default unit was radians. The second attempt involved converting the values of x to radians, but this also did not work. A tip was given to change the parentheses in the equation to ensure multiple values were plotted and a suggestion was made to change the starting index from 0 to 0.01 to avoid potential problems.
  • #1
Lolsauce
23
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
  • #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.
 

1. How do I plot a simple sin function?

To plot a simple sin function, you will need to have a mathematical software or programming language that supports plotting graphs, such as MATLAB or Python. Then, you can use the sin function (usually denoted as sin(x)) and specify the range of values for the x-axis to plot the function.

2. Why is my simple sin function not plotting correctly?

There could be several reasons why your sin function is not plotting correctly. Some common reasons include incorrect input values, incorrect syntax, or using the wrong plotting function. Double-check your inputs and make sure you are using the correct syntax and plotting function for your software or programming language.

3. Can I plot a simple sin function by hand?

Yes, you can plot a simple sin function by hand using a graphing calculator or graph paper. Start by choosing a range of values for the x-axis, then calculate the corresponding y-values using the sin function. Plot the points on the graph and connect them with a smooth curve to get the graph of the sin function.

4. How can I adjust the appearance of my sin function plot?

Most mathematical software and programming languages offer various options to adjust the appearance of your sin function plot. These options may include changing the color, line style, and adding labels and titles. Refer to the specific documentation of your software or programming language for more details on how to customize your plot.

5. Can I plot a sin function with multiple periods?

Yes, you can plot a sin function with multiple periods by adjusting the range of values for the x-axis. For example, if you want to plot two periods of the sin function, you would need to specify a range of values from 0 to 4π (or 0 to 360° if using degrees). This will result in two complete cycles of the sin function on the graph.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
617
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
694
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
839
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top