Switch case structure, I needed to show all units in this excercise
1 回表示 (過去 30 日間)
古いコメントを表示
How to fix this, I want to display all the units for this switch structure to work!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1253177/image.png)
3 件のコメント
Dyuman Joshi
2023 年 1 月 5 日
What exactly are you trying to do?
Say the value of vienibas is 3. What should be the output?
And are the last three lines part of the code or are they the result you are expecting?
回答 (1 件)
Fangjun Jiang
2023 年 1 月 5 日
編集済み: Fangjun Jiang
2023 年 1 月 5 日
use if-elseif,
When you have logical comparison in the case statement, it results in true or false (1 or 0 in value). The resulting effect is not what you think it is.
It is a mis-understanding of the switch-case programming. Please read the help document and look at the examples.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!