Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
John Wuestman
John Wuestman le 14 Avr 2022
Réponse apportée : Chunru le 14 Avr 2022
%%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):

Réponses (1)

Chunru
Chunru le 14 Avr 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

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by