显示Y轴从-1到1的刻度

时间:2014-01-23 23:07:50

标签: matlab plot subplot

我正在编写一个Matlab脚本来绘制一个频率为5Hz的常规正弦波,每隔0.01秒采样一次。我正在努力实现这个目标..

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

但我正在接受这个......

My result with it showing ticks at every .2

我只想让我的图表显示-1到1。

这是matlab代码......

% 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');

请关注如何实现这一点的任何线索将不胜感激。

感谢。

1 个答案:

答案 0 :(得分:3)

如果您问如何删除Y轴上的额外刻度,可以使用:

set(gca,'ytick',[-1 0 1]);

否则,我认为我们需要更多描述。