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!