Mean of Normal Distribution

Hello, we are trying to find the normal distribution of an array using the code below. However we are receiving the error that X must be a numeric column vector. Is there any way to apply the function to all columns? Thanks!

 Accepted Answer

Adam Danz
Adam Danz on 28 Oct 2020
Edited: Adam Danz on 28 Oct 2020
"Is there any way to apply the function to all columns?"
Yes, use varfun(), assuming the table contains all numeric values.
mu = varfun(@mean, FilledTrtnPos)
or
fitTable = varfun(@(c)fitdist(c,'Normal'), array2table(rand(10,4)))

4 Comments

My apologies, I should have specified we are stuck on the normal distribution earlier, as we can not get it for each of the columns in our array. Thank you for the info though! It will likely be of great use later.
Why doesn't my answer address that?
A normal distribution has 2 parameters: center (mean) and width (standard deviation). varfun could be used to compute both for each column of a table.
You are correct, my apologies I misunderstood a normal distribution earlier.
No prob. Glad I could help.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2020a

Asked:

on 28 Oct 2020

Commented:

on 29 Oct 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!