Running an inner loop multiple times.
Show older comments
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 Comments
KSSV
on 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
on 11 Oct 2021
Accepted Answer
More Answers (1)
Colin Gowling
on 12 Oct 2021
0 votes
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!