Effacer les filtres
Effacer les filtres

Why do i keep getting the illegal error us of "end"

1 vue (au cours des 30 derniers jours)
Sierra Bounds
Sierra Bounds le 20 Fév 2019
Modifié(e) : Stephen23 le 20 Fév 2019
eaas3.PNG
  1 commentaire
Stephen23
Stephen23 le 20 Fév 2019
Modifié(e) : Stephen23 le 20 Fév 2019
'Why do i keep getting the illegal error us of "end"'
Check the spelling of "function".

Connectez-vous pour commenter.

Réponse acceptée

Asad Mirza
Asad Mirza le 20 Fév 2019
For every start of a loop you write in MATLAB you must "end it" with an "end". They come in pairs.
Now it looks like you did properly close your loop but you incorrectly wrote "funcion" instead of "function", that is where you error it actually coming from.
function vari = variance(a)
total = sum(a);
width = length(a);
avg = total/width;
v=0;
for c = 1 : legnth(a)
v = v +(a(c)-avg)^2;
end
vari = v / (width-1);
end

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by