如何绘制分段常数和分段波函数的信号

时间:2017-02-06 06:29:04

标签: matlab signals matlab-figure

我是Matlab的新手。如何绘制包含常数,波函数和另一个常数的信号,如下图所示?

signal

1 个答案:

答案 0 :(得分:0)

figure % create a figure
hold on % Keep plot when making more plots

% first section
plot([0,9],[2500 2500],'k') % plot a constant line from 0-9 where y = 2500

% second section
x = linspace(0,9); % create array from 0 to 9 in 100 points
f = @(x) 2500 + sin(x*pi/9)*2500; % create wave function, using x
plot(x+9,f(x),'k')

% third section
plot([18,24],[2500 2500],'k') % plot a constant line from 18-24, y = 2500

% Change y limits
ylim([0 5000])