how can jump and go another line in a m-file?
조회 수: 25 (최근 30일)
이전 댓글 표시
how can jump and go another line in a m-file. for example:
if a=b;
a=0;
else
(jump ***line)
end
----other commands
----other commands
.
.
.
***line
댓글 수: 1
Gerrit Verboom
2021년 3월 28일
Please, don't call me lazy when I want to use a kind of jump to or goto.
Regards,
Gerrit Verboom
채택된 답변
Paulo Silva
2011년 8월 31일
MATLAB doesn't allow silly GOTO type functions, make conditions and create functions, or the easy and dumb way:
if a=b;
a=0;
else
----other commands
----other commands
end
If those other commands repeat themselves often you should make a function with them and call that function whenever you need it.
댓글 수: 1
Satyam Nigam
2020년 5월 21일
for j=k:-1:3
binary_conv=(q(j)+q(j-1));
if(binary_conv<2)
f(g)=q(j);
g=g+1;
else
n=0;
break;
end
end
i need to use break here. now tell me an alternative??
추가 답변 (1개)
Walter Roberson
2011년 8월 31일
댓글 수: 2
Paulo Silva
2011년 8월 31일
mohammad, jumping to lines of code is very lazy and does more harm than good, if you want to be a good programmer don't do it that way, learn to use functions and conditions to control the flux of your code.
참고 항목
카테고리
Help Center 및 File Exchange에서 Software Development Tools에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!