plotting a sin wave

Here are the MATLAB commands to create a simple plot of y = sin(3*pi*x) from 0 to 2*pi. For your convenience these commands are also stored in the sin3xPlot.m script file. (Refer to ``help with downloading scripts'' for instructions on downloading this script to your computer.)
>> x = 0:pi/30:2*pi; % x vector, 0 <= x <= 2*pi, increments of pi/30
>> y = sin(3*x); % vector of y values
>> plot(x,y) % create the plot
>> xlabel('x (radians)'); % label the x-axis
>> ylabel('sine function'); % label the y-axis
>> title('sin(3*x)'); % put a title on the plot

The effect of the labeling commands, xlabel, ylabel, and title are indicated by the text and red arrows in the figure. Don't skimp on the labels!


thumbnail
About The Author

Ut dignissim aliquet nibh tristique hendrerit. Donec ullamcorper nulla quis metus vulputate id placerat augue eleifend. Aenean venenatis consectetur orci, sit amet ultricies magna sagittis vel. Nulla non diam nisi, ut ultrices massa. Pellentesque sed nisl metus. Praesent a mi vel ante molestie venenatis.

0 comments