Borrar filtros
Borrar filtros

How should I fix my convolutional integral

2 visualizaciones (últimos 30 días)
Faezeh Manesh
Faezeh Manesh el 9 de Mzo. de 2020
Comentada: Steve Chou el 15 de Mzo. de 2021
Hello all,
Actually, I am trying to convolve two functions (f and y)using the following MATLAB code:
close all;
clear all;
clc;
%set time vector
t0=0;
tf=100;
N=10000;
dt=(tf-t0)/N;
t=t0:dt:tf;
T0=60;
alpha=1;
beta=0.01;
%construct the firxt part of the convolution
for i=1:length(t)
if(t(i)<=T0)
y(i)=0;
else
y(i)=alpha+beta*(t(i)-T0);
end
end
%plot y(t)
subplot(1,2,1);
plot(t,y,'LineWidth',2);
title('y(t)');
%Second function of the convolution
f2= 0.08787*exp(-((t-63.08)/1.593).^2);
%Convolution of these 2 functions
z=conv(y,f2,'full');
con = z*dt;
subplot(1,2,2);
plot(t,f2,'LineWidth',2);
title('f2');
t = (1:length(con))*dt ;
hold on;
plot(t,con,'LineWidth',2);
I tried to use the guidlines in the following link to run a full convolutional integral :
Here are my results:
This result seems not to be reasonable because both my functions start rising at x=60 but my convolution starts rising at x=120. Can someone helps me with this problem.
  1 comentario
Matt J
Matt J el 9 de Mzo. de 2020
Editada: Matt J el 9 de Mzo. de 2020
This result seems not to be reasonable because both my functions start rising at x=60
There's nothing unreasonable about that. That is theoretically what should happen if both functions start at t=60. For the convolution result to start at t=60, you need one of the signals to start at t=0.

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 9 de Mzo. de 2020
Editada: Matt J el 9 de Mzo. de 2020
This might be what you want,
subplot(1,2,1);
ty=t;
plot(ty,y,'LineWidth',2);
title('y(t)');
%Second function of the convolution
f2= 0.08787*exp(-((t-63.08)/1.593).^2);
%Convolution of these 2 functions
z=conv(y,f2(find(f2,1):end),'same');
con = z*dt;
subplot(1,2,2);
plot(ty,f2,'LineWidth',2);
title('f2');
hold on;
tc=linspace(0,1,numel(con));
tc=tc/tc(2)*dt;
plot(tc,con,'LineWidth',2);
hold off
  3 comentarios
Matt J
Matt J el 10 de Mzo. de 2020
Editada: Matt J el 10 de Mzo. de 2020
As I said in my comment above,
I think you've had the correct result from the very beginning.
Steve Chou
Steve Chou el 15 de Mzo. de 2021
This chart is more clear to read.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by