필터 지우기
필터 지우기

How can I correct if else to not get this error?

조회 수: 2 (최근 30일)
John Wuestman
John Wuestman 2022년 4월 14일
답변: Chunru 2022년 4월 14일
%%Part 3
%
m=11;
if m>=3 && m<=5
disp('Spring')
elseif m>=6 && m<=8
disp('Summer')
elseif m>=9 && m<=11
disp('Fall')
elseif m>=1 && m<=2 && m==12
disp('Winter')
elseif m>=13 && m<=0
disp('null')
end
Execution of script MATLABex as a function is not supported:
/MATLAB Drive/MATLABex.m
Error in LiveEditorEvaluationHelperEeditor2AA50624 (line 24)
month = input("Enter month of birthday(as a nummber): ");
Enter month of birthday(as a nummber):

답변 (1개)

Chunru
Chunru 2022년 4월 14일
The code has some logical errors (with correction below).
For the error "Execution of script MATLABex as a function is not supported: /MATLAB Drive/MATLABex.m", you need to show the file "MATLABex.m" so that we can help.
for m=1:12
if m>=3 && m<=5
disp('Spring')
elseif m>=6 && m<=8
disp('Summer')
elseif m>=9 && m<=11
disp('Fall')
elseif (m>=1 && m<=2) || m==12 % ||
disp('Winter')
elseif m>=13 || m<=0 % ||
disp('null')
end
end
Winter Winter
Spring Spring Spring
Summer Summer Summer
Fall Fall Fall
Winter

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by