Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Am I implementing the convolutional integral correctly?

1 Ansicht (letzte 30 Tage)
Faezeh Manesh
Faezeh Manesh am 5 Mär. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hello all,
Actually, I am trying to calculate the convolutional integral of two functions using the following code:
close all;
clear all;
clc;
%set time vector
t = linspace(0,85,16384);
T0=60;
alpha=1;
beta=0.1;
%construct the first part of the convolution
for i=1:size(t,2)
if(t(i)<=T0)
y(i)=alpha/1.5;
else
y(i)=(alpha+beta*(t(i)-T0))/1.5;
end
end
%plot the first function of the convolution
figure;
plot(t,y,'linewidth',2);
ylim([-1 3.5]);
set(gca,'fontsize',14,'fontweight','bold');
grid on;
xlabel('t');
ylabel('y(t)');
title('First function of the convolution');
%second part of the convolution
for i=1:size(t,2)
f2(i) = 0.08787*exp(-((t(i)-63.08)/1.593).^2);
end
%plot the second function of the convolution
figure;
plot(t,f2,'linewidth',2);
legend('f2')
xlim([50 85]);
set(gca,'fontsize',14,'fontweight','bold');
grid on;
xlabel('t');
ylabel('f2(t)');
title('Second function of the convolution');
%compute the convolution using matlab function
z2 = median(diff(t))*conv(y,f2,'same');
%plot the matlab convolution
figure;
plot(t,z2,'linewidth',3);
legend('f2*y')
grid on;
xlabel('t');
ylabel('y_*f');
title('Result of the convolution');
hold on;
The first and second part of my convolutional integral are as follows:
and the result of the convolution is as follows:
But the strange point is that both of my functions (y and f2) are constant until t=60 but the result of the convolution starts from t=20. I don't know what's wrong with my implementation. Does anyone have any idea regarding my code? Am I implementing the convolutional integral correctly?

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by