Borrar filtros
Borrar filtros

Calculating a convolution using conv vs. a loop

4 visualizaciones (últimos 30 días)
Senaasa
Senaasa el 25 de Jun. de 2013
Hi,
I'm currently calculating the convolution of a Gaussian and a power law using the following code snippet:
for j=1:1:size(Axis_Tw,1)
t = Axis_Tw(j);
if Axis_Tw(j) <= 100
temp = 0;
CPara = 0;
for i=1:1:nt+1
CPara = CPara + Gas(temp,Gparams)*PowerLaw(t-temp,Eparams)*dt;
temp = temp + dt;
end
FPara(j) = CPara;
else
FPara(j) = PowerLaw(t,Eparams);
end
end
I'm trying to use conv to do this instead of a loop. I'm confused on how to do this. Can conv take functions as arguments or can I only use vectors? I've tried evaluating Gas and PowerLaw for Axis_Tw and then passing those arrays into conv, but the result is very different (as in several hundred orders of magnitude).
Thanks, Charles

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by