필터 지우기
필터 지우기

Calculating a convolution using conv vs. a loop

조회 수: 1 (최근 30일)
Senaasa
Senaasa 2013년 6월 25일
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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by