Determine the number of "for" loops by the user
Show older comments
Hi everyone
I want to write a code that takes the number of uncertain parameters from the user and creates a "for" loop according to their number and performs the calculations.
for example:
The user enters the number 4 as the number of uncertainty parameters and the code puts 4 "for" loops in a row. This way :
for i=1:I
for j=1:J
for k=1:K
for r=1:R
"calculations"
end
end
end
end
Is this possible in MatLab?
4 Comments
Wan Ji
on 27 Aug 2021
Use while instead
DGM
on 27 Aug 2021
How does while address the question? The number of iterations is known; the number of nested loops is not.
f4r3in
on 27 Aug 2021
KSSV
on 27 Aug 2021
I think you can avoid using loops.....can you tell us what are those calculations?
I,J,K,R they will be always same?
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!