Avoiding doble loops to gain efficience
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!