?? 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 + -