Running an inner loop multiple times.
Mostrar comentarios más antiguos
Hi all,
I'm a novice with Matlab. I have the following code that works, however I want to run the loop multiple times (number_of_runs), (montecarlo sim).
I'm assuming i need another loop, but i'm having no luck, i.e. exceeding numbers of arrays or generating more columns.
For example if the nth_failure = 10, i want the output of 10 columns for x and t, with the number_of_runs being a defined number of rows. Averaging each column.
for i = 2:nth_failure
p(i) = rand;
r_t_T = (p(i) .* exp(-(v(i-1)./n).^b));
x(i) = ((n .* (-log(r_t_T)).^(1./b))-v(i-1));
t(i) = t(i-1) + x(i);
v(i)= qf*(v(i-1)+x(i));
end
any help appreciated.
Cheers
2 comentarios
KSSV
el 11 de Oct. de 2021
Are you getting any error with the above code? What error? We don't know the dimensions of other varbales to help you.
Colin Gowling
el 11 de Oct. de 2021
Respuesta aceptada
Más respuestas (1)
Colin Gowling
el 12 de Oct. de 2021
0 votos
Categorías
Más información sobre Graphics Performance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!