Set upper and lower bounds of for loop
조회 수: 11 (최근 30일)
이전 댓글 표시
I would like to set the upper and lower bounds of a for loop based on the values of simulation parameters. I'm not sure how to do this in Matlab. So something like
if Sim == "A"
if FluorProf == 1
SimText = "(N+1)/2:N"
else
SimText = "1:N"
end
else
SimText = "1:(N+1)/2-1"
end
for k = SimText
@Do something
end
댓글 수: 0
채택된 답변
Cris LaPierre
2021년 8월 23일
Have SimText be a vector instead of a string, and your for loop should run as expected.
a = 1:3;
for b = a
b
end
댓글 수: 0
추가 답변 (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!