Matlab 阶跃函数定义

已知两序列 x[n]=0.8*exp(n)*(u[n]-u[n-5]) h[n]=[1 1 1 1 1]
用MATLAB计算两序列的卷积并绘制其波形。
谢谢!

n1=0:10;

Xn1=0.8*exp(n1).*(heaviside(n1)-heaviside(n1-5));

n2=0:4;

Xn2=ones(1,5);

nys=n1(1)+n2(1);

nyf=n1(end)+n2(end);

y=conv(Xn1,Xn2); 

ny=[nys:nyf];

figure(1)

stem(n1,Xn1);

figure(2);

stem(n2,Xn2);

figure(3)

stem(y,ny);

温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-01-04
%by dynamic
%see also
%contact me [email protected]
%2009.2.
%

% Matlab中符号计算中提供
% 单位阶跃函数heaviside(t-a)
% 单位脉冲函数dirac(x-a)
% 至于斜坡可以使用阶跃和直线方程构成
%
%比如要绘制a=4时的阶跃函数
f=@(t)heaviside(t-4);
ezplot(f,[0 5])
%
%绘制a=2时的脉冲信号
f=@(x)dirac(x-2);
ezplot(f,[0 5])%这个在图形上没法显示
%
%至于在t=1时发生转折为斜率为1的斜坡可以表示为
f=@(t)t.*heaviside(t-1)-heaviside(t-1);
ezplot(f,[0 3])

其他斜坡信号可以自己看下规律自己组织,很简单的本回答被网友采纳