How can I use elements of a vector for the '' for loop '' ?
1 view (last 30 days)
Show older comments
I want to code some simple formulas for the ultimate strength calculation of ship panels. I have coded nested for loop in a function. Inner loop uses elements of a vector as loop boundary. But in this case, it gives some incorrect results. Related part of my code is attached. In my code N is a vector whose dimension is kx1. I have to use every single element of N vector as boundary for inner loop. Other vectors have been calculated previously.
Thank you so much in advance.
Best Regards.
Murat
7 Comments
Geoff Hayes
on 13 Sep 2014
So what value does the code read if not the intended N(i)? Please add the following line of code as the first line in the inner for loop
fprintf('N(i)=%d i=%d j=%d\n',N(i),i,j);
Just have the code run for the first handful of i (maybe 1 through to 5 or so) and observe the output of the above fprintf. Paste it back here and indicate what the code should read versus what it is reading.
Answers (0)
See Also
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!