How to make convolution code without using conv
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to make convolution without using 'conv'. The code in below is that I did, and right side of a attached pic is result that I should make.
clc
clear
close all
t= -5:0.001:5;
x= (t>=0)&(t<=1);
h= (t>-2)&(t<0);
X=[x,zeros(1,length(t))];
H=[h,zeros(1,length(t))];
for i=1:length(t)
Y(i)=0;
for j=1:numel(t)
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
else
end
end
end
figure;
subplot(3,1,1);
plot(t,x);
xlabel('t');
ylabel('x(t)');
xlim([-5 5]);
ylim([-0.5 1.5]);
grid on;
subplot(3,1,2);
plot(t,h);
xlabel('t');
ylabel('h(t)');
xlim([-5 5]);
ylim([-0.5 1.5]);
grid on;
subplot(3,1,3);
plot(t,Y);
xlabel('t');
ylabel('y(t)');
xlim([-5 5]);
ylim([0 1000]);
grid on;

0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Subplots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!