MATLAB: Problem 106. Weighted average

homeworkproblem

function y = weighted_average(x,w)
f=x.*y;
f=sum(f);
y=f/length(x);
end
is there any error. i submit and get WA(wrong answer).

Best Answer

Instead of
f=x.*y
shouldn't it be
f=x.*w
I can't see how you get any output at all, whether correct or incorrect. You should be getting an error message.