フィルターのクリア

How to write case in simple way ?

1 回表示 (過去 30 日間)
Henry Buck
Henry Buck 2016 年 3 月 23 日
コメント済み: Henry Buck 2016 年 3 月 27 日
Hi,
Is there a simple/short way to write switch case ?
instead : case {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20} ... ... otherwise ...
something like case 1 to 20 or case {1:20} ?
Thanks,
Henry

採用された回答

per isakson
per isakson 2016 年 3 月 24 日
編集済み: per isakson 2016 年 3 月 24 日
One way
>> cssm(12)
12
where
function cssm(jj)
switch jj
case num2cell([1:24])
disp( jj )
otherwise
disp('failed')
end
end
And
case num2cell([1:24])
may be replaced by
case num2cell(1:24)
in contemporary releases of Matlab
  1 件のコメント
Henry Buck
Henry Buck 2016 年 3 月 27 日
Great ! Thanks a lot.
Henry

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by