Problem 106. Weighted average
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
ricardo gunawan
le 15 Juil 2013
Réponse apportée : VELDANDI THARUN
le 10 Jan 2020
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 commentaires
Réponse acceptée
Matt J
le 15 Juil 2013
Modifié(e) : Matt J
le 15 Juil 2013
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 commentaires
Jan
le 15 Juil 2013
@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.
Plus de réponses (1)
VELDANDI THARUN
le 10 Jan 2020
function y = weighted_average(x,w)
y =(x*w.')/length(x)
end
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!