Conv function gives unexpected error

2 visualizaciones (últimos 30 días)
Au.
Au. el 11 de Abr. de 2022
Respondida: Matt J el 11 de Abr. de 2022
Hello everyone,
I am again raising the convolution topic - sorry!
I need to convolute a gaussian, a heaviside and an exponential decay function.
Just using, for example, conv(gaussian,hea,'same') gives me always the following error:
'Subscript indices must either be real positive integers or logicals.'
this is the code i am using:
t=-5:0.1:10;
gaussian=exp(-((t-0.15)/0.164).^2);
hea=(0.2*heaviside(t-0.15));
exp_decay=(exp(-((t-0.15)/0.300)));
func=conv(hea,gaussian,'same');
I found a way arround using the erf fuction, but i do not understand what is the problem... and it would be really useful to be able to use the conv function.
Thank you so much for your answer!
Audrey
  2 comentarios
Stephen23
Stephen23 el 11 de Abr. de 2022
Your code works without error:
t = -5:0.1:10;
gaussian = exp(-((t-0.15)/0.164).^2);
hea = (0.2*heaviside(t-0.15));
exp_decay = (exp(-((t-0.15)/0.300)));
func = conv(hea,gaussian,'same')
func = 1×151
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0022 0.0218 0.1084 0.2907 0.4729
Au.
Au. el 11 de Abr. de 2022
Hello Stefen,
very embarrassed to recognize it does...
thank you for the fast reply!

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 11 de Abr. de 2022
Clear the variable called conv from your workspace
clear conv

Más respuestas (0)

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by