MATLAB Online does not run script properly

8 vues (au cours des 30 derniers jours)
Kiam Heong Kwa
Kiam Heong Kwa le 9 Mai 2022
Commenté : Cris LaPierre le 10 Avr 2024
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 commentaires
Dyuman Joshi
Dyuman Joshi le 10 Avr 2024
@Martin, Have you tried searching on the internet or on this forum for the same?
Cris LaPierre
Cris LaPierre le 10 Avr 2024
This is unrelated to this question. Please ask this in a new question.

Connectez-vous pour commenter.

Réponses (1)

Cris LaPierre
Cris LaPierre le 9 Mai 2022
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 commentaires
Cris LaPierre
Cris LaPierre le 9 Mai 2022
The full code runs fine for me.
Kiam Heong Kwa
Kiam Heong Kwa le 9 Mai 2022
This helps! Thanks a lot!
Take care.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by