How can I get a variable from inside of the for loop and use it after it ends?
조회 수: 2 (최근 30일)
이전 댓글 표시
if (M ~= M2)
C=padarray(x,[21,0],0,'post');
sz=size(C)
end
I would like to use 'sz' outside the loop for the rest of my code
댓글 수: 1
James Tursa
2018년 3월 20일
What is preventing you from doing so? Is the code you show inside of your loop? It would help if you show that code also so we can better understand your problem.
채택된 답변
Amjad Green
2018년 3월 20일
if you want the value of the variable at a certain point in the for loop,you can save it in a different variable at that iteration then after the for loop is finished save it back int its original variable name
추가 답변 (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!