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

12 次查看(过去 30 天)
eaas3.PNG
  1 个评论
Stephen23
Stephen23 2019-2-20
编辑:Stephen23 2019-2-20
'Why do i keep getting the illegal error us of "end"'
Check the spelling of "function".

请先登录,再进行评论。

采纳的回答

Asad Mirza
Asad Mirza 2019-2-20
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by