Reputation: 362
I am writing a Matlab script to plot a regular sine wave with a frequency of 5Hz sampled every .01 second. I am trying to achieve this..
But I am gettting this..
I just want my graph to show -1 to 1.
Here is the matlab code...
% Script that will show stem plots of a sine wave with a frequency of
% 5Hz sampled every .01 seconds.
time = [0:.01:0.5]; % Sampling time 0 - 10 seconds at a rate of .01 second
frequency = 5; % The frequency is 5 Hz
samplingFrequency = .01;
fc = frequency/samplingFrequency;
sineWave = sin(2*pi*frequency*time);
figure(1)
plot(time, sineWave);
figure(2)
stem(time, sineWave, ':r');
Please any clue on how to achieve this would be appreciated.
Thanks.
Upvotes: 1
Views: 106
Reputation: 12345
If you are asking how to remove the extra ticks on the Y axis, you can use this:
set(gca,'ytick',[-1 0 1]);
Otherwise, I think that we'll need more description.
Upvotes: 3