How to use Switch case and if else in Embedded Matlab Function

2 ビュー (過去 30 日間)
niharika
niharika 2012 年 12 月 24 日
I am trying to put an ifelse condition under switch statements in Embedded Matlab Function. Can anyone suggest me the correct way of syntax used in Embedded Matlab Function.
Thanks in Advance.

回答 (1 件)

Laura Proctor
Laura Proctor 2012 年 12 月 24 日
You can use the same syntax that you would in MATLAB. Here are links to the documentation for if and switch.
  2 件のコメント
niharika
niharika 2012 年 12 月 26 日
If I use the syntax in MATLAB also I am getting an error as "Output argument is not assigned on some execution paths"
Could you please help me where am i going wrong.
Walter Roberson
Walter Roberson 2012 年 12 月 26 日
Initialize the output before you enter the switch().
Currently, one of the choices you have in the switch does not always assign a value to the output. For example, if you had
if length(A) > 5
B = A + 1;
else
warn('A is too short');
end
then that code does not assign a value to B in the case of the warning.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by