How to make convolution code without using conv

88 visualizzazioni (ultimi 30 giorni)
건중 박
건중 박 il 18 Mag 2021
Modificato: Matt J il 18 Mag 2021
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;

Risposte (0)

Categorie

Scopri di più su Sparse Matrices in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by