SWich/case code

조회 수: 2 (최근 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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by