How to use switch statement
4 ビュー (過去 30 日間)
古いコメントを表示
I need to create a function through switch statements that are from one bound to the next bound. How would i use the case to display bound1 through bound2. Every variable falling within the bounds is included in the case.
i have
switch n
case {bound1 through bound2}
2 件のコメント
採用された回答
Matt J
2022 年 10 月 14 日
No, do it like this:
[lettergrade] = curvedGrade(71,[90,80,70,60, 50])
function [lettergrade] = curvedGrade(grade,bound)
gradeList=flip(["A" "B" "C" "D" "F"]);
idx=discretize(grade,[flip(bound(:));100]);
lettergrade=gradeList(idx);
end
0 件のコメント
その他の回答 (1 件)
Walter Roberson
2022 年 10 月 14 日
https://www.mathworks.com/help/matlab/ref/double.discretize.html and switch on the bin number.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Introduction to Installation and Licensing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!