recipes : Plotting : Line and Scatter Plots : How do I plot a sine wave?

Problem

How do I plot a sine wave in?

Solution

To plot one cycle of a sine wave you can use the following code.

x=-1:0.001:1;
nCycles=1; %Try modifying this to alter the number of cycles
y=sin(x*pi*nCycles);
plot(x,y)