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.

采纳的回答

Fangjun Jiang
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 CenterFile Exchange 中查找有关 Argument Definitions 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by