Borrar filtros
Borrar filtros

Avoiding doble loops to gain efficience

1 visualización (últimos 30 días)
Javier
Javier el 13 de En. de 2014
Editada: Matt J el 13 de En. de 2014
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

Respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by