Clear Filters
Clear Filters

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

2 views (last 30 days)
%%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):

Answers (1)

Chunru
Chunru on 14 Apr 2022
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

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!