SWich/case code

1 回表示 (過去 30 日間)
Jorge Hernandez
Jorge Hernandez 2021 年 4 月 19 日
回答済み: Shivang Srivastava 2021 年 4 月 23 日
  1 件のコメント
Geoff Hayes
Geoff Hayes 2021 年 4 月 19 日
編集済み: Geoff Hayes 2021 年 4 月 19 日
Jorge - since this is homework, please discuss what you have attempted so far. If you have a specific question, then please ask it so that we can get a better idea of where you might be stuck.

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

回答 (1 件)

Shivang Srivastava
Shivang Srivastava 2021 年 4 月 23 日
I would recommend you try to solve the question yourself before going through the solution.Here is the solution for your reference:
function [output] = switchcaseWeekdays(n)
switch n
case 1
output = "Sunday";
case 2
output = "Monday";
case 3
output = "Tuesday";
case 4
output = "Wednesday";
case 5
output = "Thursday";
case 6
output = "Friday";
case 7
output = "Saturday";
otherwise
output = "Not a valid input";
end
end
For more information do check the Switch Case Documentation.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by