Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
John Wuestman
John Wuestman el 14 de Abr. de 2022
Respondida: Chunru el 14 de Abr. de 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):

Respuestas (1)

Chunru
Chunru el 14 de Abr. de 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

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by