MATLAB Online does not run script properly
33 次查看(过去 30 天)
显示 更早的评论
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
2024-4-10,7:15
@Martin, Have you tried searching on the internet or on this forum for the same?
Cris LaPierre
2024-4-10,12:40
This is unrelated to this question. Please ask this in a new question.
回答(1 个)
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
8 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!