How can I use elements of a vector for the '' for loop '' ?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Geoff Hayes
2014년 9월 13일
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.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!