Question

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..

Ticks showing from -1 to 1 without all the intermediary ticks in between

But I am gettting this..

My result with it showing ticks at every .2

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top