필터 지우기
필터 지우기

Avoiding doble loops to gain efficience

조회 수: 1 (최근 30일)
Javier
Javier 2014년 1월 13일
편집: Matt J 2014년 1월 13일
Hi.
I have solved a problem by using a doble loop but it is taking too long and I am pretty sure there are more efficient ways to solve it, but I am quite a begginer with the program. I would be glad if you could help me with this.
Basically, I have two arrays of different size and I want to multiply each element of the first array for all the elements of the second one. The second vector also changes size in every iteration and that's why I have ended with a doble loop. I am doing something like this.
for j=1:length(s)
t=T-s(j):0.00025:T-0.00025;
for i=1:length(x)
aux1=exp(-x(i)^2/2./(T-t))./((t.*(T-t)).^(3/2));
aux2=sum(aux1)*0.00025;
omega(i)=exp(-mu^2/2*T+mu.*x(i)).*x(i)/2/pi.*aux2;
end
aux3=sum(omega)*0.00025;
Psnj(j)=aux3*exp(-lambda*s(j));
end
How could I do this more efficiently?
Thank you in advance Javier

답변 (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