Running an inner loop multiple times.
Afficher commentaires plus anciens
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 commentaires
KSSV
le 11 Oct 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
le 11 Oct 2021
Réponse acceptée
Plus de réponses (1)
Colin Gowling
le 12 Oct 2021
0 votes
Catégories
En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!