Why do i keep getting the illegal error us of "end"
4 views (last 30 days)
Show older comments
![eaas3.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/205132/eaas3.png)
1 Comment
Accepted Answer
Asad Mirza
on 20 Feb 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
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!