is it posibile in matlab, jump to others command if a=1( i dont want if a~=1)
1 次查看(过去 30 天)
显示 更早的评论
this is opposite of 'if-end' command.i need if something happens then don't do some certain command. for example:
if a==1 don't do under command until end
commands
end
other command %that if a=1 then jump here
its not needed 'if a~=1' because there are a lot of cases that a~=1 but needs command after 'if', be run too.
0 个评论
采纳的回答
Fangjun Jiang
2011-9-7
There is no "goto" command in MATLAB if that is what you are looking for. There should be other ways to control your code flow if you could elaborate your need.
Maybe consider "switch-case". help switch. Change the value of a below to see the effect.
a=1;
switch num2str(a)
case {'2','3'}
disp('a is 2 or 3');
case {'1','4','5'}
disp('a is 1 or 4 or 5');
otherwise
disp('a is not valid');
end
3 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Argument Definitions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!