필터 지우기
필터 지우기

a function insdie a switch case

조회 수: 15 (최근 30일)
Bader Herzallah
Bader Herzallah 2020년 4월 23일
답변: Steven Lord 2020년 4월 23일
how can i put a functon code inside a switch case
  댓글 수: 1
Ameer Hamza
Ameer Hamza 2020년 4월 23일
Can you further describe what you want you are trying to do?

댓글을 달려면 로그인하십시오.

채택된 답변

Steven Lord
Steven Lord 2020년 4월 23일
You cannot define a function inside a switch-case statement as stated on this documentation page.
"You cannot define a nested function inside any of the MATLAB® program control statements, such as if/elseif/else, switch/case, for, while, or try/catch."
If you want your nested function to be nested inside the function that contains the switch-case statement, define it nested inside that function but outside all control statements
You can call functions inside a case or otherwise section of a switch-case statement or to generate the expression on which you switch. The examples on the documentation page for the switch keyword show this using disp, bar, title, pie3, and warning. So does this example:
switch input('Enter a number: ')
case 1
disp('The One')
otherwise
warning('Not The One')
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by