フィルターのクリア

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 Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by