Skip to content

Instantly share code, notes, and snippets.

@hurutoriya
Last active February 1, 2017 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hurutoriya/d3470875e9276b470e313a842e353223 to your computer and use it in GitHub Desktop.
Save hurutoriya/d3470875e9276b470e313a842e353223 to your computer and use it in GitHub Desktop.
Compute Weighted Average of Vector by MATLAB
function [weightedAve] = weightedAverage(data)
h = histogram(data);
k = ([min(data):max(data)]*h.Values')/length(data)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment