MATLAB Online does not run script properly

조회 수: 8 (최근 30일)
Kiam Heong Kwa
Kiam Heong Kwa 2022년 5월 9일
댓글: Cris LaPierre 2024년 4월 10일
I ran the following script (which I named draft.m) through MATLAB Online:
clear;
fun = @(x, b) (b-7)*(b+5)*x.^2-2*x+3;
brange = -8:0.1:10;
fmin = [];
for b = brange
end
and got the following error message:
>> draft
Error: File: draft.m Line: 6 Column: 1
At least one END is missing. The statement beginning here does not have a matching end.
But if I remove the line
fmin = [];
then it works. Did I miss something? I suppose defining an empty array shouldn't fail the for loop, should it? Thank you very much in advance for any comments that you may have.
  댓글 수: 3
Dyuman Joshi
Dyuman Joshi 2024년 4월 10일
@Martin, Have you tried searching on the internet or on this forum for the same?
Cris LaPierre
Cris LaPierre 2024년 4월 10일
This is unrelated to this question. Please ask this in a new question.

댓글을 달려면 로그인하십시오.

답변 (1개)

Cris LaPierre
Cris LaPierre 2022년 5월 9일
Code runs without error for me. I can also run it here without error. Perhaps try again? If it happens again, perhaps there are more details you can share about what you are doing?
clear;
fun = @(x, b) (b-7)*(b+5)*x.^2-2*x+3;
brange = -8:0.1:10;
fmin = [];
for b = brange
end
b
b = 10
  댓글 수: 8
Cris LaPierre
Cris LaPierre 2022년 5월 9일
The full code runs fine for me.
Kiam Heong Kwa
Kiam Heong Kwa 2022년 5월 9일
This helps! Thanks a lot!
Take care.

댓글을 달려면 로그인하십시오.

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by