Reputation: 59
I've plotted a sin wave that takes one second to complete an oscillation and has an amplitude of one.
F = 1 ;
A = 1 ;
x = linspace (0,1,100) ;
y = A * sin(2 * pi * F * x) ;
plot(x, y, 'b.-'),xlim([0 3.5]),ylim([-1 1]);
The problem is, only one oscillation is plotted on the graph. How can I get more cycles or oscillations to be plotted?
Upvotes: 1
Views: 46
Reputation: 23675
Your linspace
output was defined between 0
and 1
. If you want to fill the whole plot, whose x
upper limit is 3.5
, change the code as follows:
F = 1;
A = 1;
x = linspace (0,3.5,100); % from 0 to 3.5, not from 0 to 1
y = A * sin(2 * pi * F * x);
plot(x, y, 'b.-'),xlim([0 3.5]),ylim([-1 1]);
If you want to have more control over this, just define a variable which represent your x-axis
upper limit so you don't have to change too many things when you want to modify the plot:
F = 1;
A = 1;
x_hi = 3.5;
x = linspace (0,x_hi,100);
y = A * sin(2 * pi * F * x);
plot(x, y, 'b.-');
xlim([0 x_hi]);
ylim([-1 1]);
Upvotes: 3