% Convolution Program % % Input sequences f and h, determine Lf, Lh, and specify T % f=input('first signal f = ') % h=input('second signal h = ') % T=input('sampling period T = ')T=0.1 clear all T=0.1 t=0:T:10; f=sin(t); h=0.5*(exp(-t)+exp(-3*t)); Lf=length(f) Lh=length(h) for k=1:Lf+Lh-1 y(k)=0; for i=max(1,k-(Lh-1)):min(k,Lf) y(k)=y(k)+f(i)*h(k-i+1); end yzsappr(k)=T*y(k); end plot(t,yzsappr(1:length(t))) title('Approximative evaluation of the convolution (zero-state response)') xlabel('Time') ylabel('Zero-state approximative response')