📄 cconv.m
字号:
%==================================================================
% Name:cconv.m
% The program can be used to compute the convolution
% of two continuou-time signals.
% please express the signals in terms of the unit step function.
% for example:e(t)=exp(-2*t).*u(t).
%==================================================================
clear;close all;
disp('请将参与卷积运算的信号用单位阶跃函数表示出其时间范围,')
disp('例如:e(t)=exp(-2*t).*u(t)。')
t0=-10;%input('请输入信号的起始时间(建议取0—-10):');
t1=10;%input('请输入信号的终止时间(建议取0—10):');
p=0.005;
t=t0:p:t1;
x=input('请输入激励信号:');
h=input('请输入系统冲激响应:');
f=p*conv(x,h); %卷积计算
% 将卷积的结果取得和两个输入的信号一样长,
% 以便在相同的坐标中绘制其图形并方便比较。
l=length(f);
m=2*t0:p:t0-p;
n=t1+p:p:2*t1;
m1=zeros(1,abs(t0/p));
n1=zeros(1,abs(t1/p));
lm=length(m1);
ln=length(n1);
f=f([lm+1:l-ln]);
clf;
subplot(3,1,1)
plot(t,x);grid on;
title('The input signal e(t):');
subplot(3,1,2);
plot(t,h,'m');grid on;
text(0.9*t0,0.8*max(h),'The impulse response h(t):');
subplot(3,1,3);
plot(t,f,'r');%axis([t0,t1,min(f),max(f)]);
text(0.9*t0,0.8*max(f),'The output response r(t):');
xlabel('time t');grid on;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -