Problem 106. Weighted average
1 次查看(过去 30 天)
显示 更早的评论
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).
0 个评论
采纳的回答
Matt J
2013-7-15
编辑:Matt J
2013-7-15
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.
2 个评论
Jan
2013-7-15
@ricardo: The error would have been obvious, when you read the error message. The description "I get WA(wrong answer" is cryptic.
Please run this code on your computer and examine the error messages. Using the debugger is a good idea also. But letting the forum solve your Cody challenges is not a resource friendly method for this game.
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!