??? Undefined function or method 'gauss' for input arguments of type 'double'.

17 ビュー (過去 30 日間)
Nikola
Nikola 2014 年 7 月 23 日
コメント済み: Star Strider 2014 年 7 月 23 日
gauss(x,mu,s) x double mu 4.5636 s 0.5969
gauss=gauss(x,mu,s) ??? Undefined function or method 'gauss' for input arguments of type 'double'. how to fix this problem? o wanna plot distribution of variable "x"

回答 (4 件)

Wayne King
Wayne King 2014 年 7 月 23 日
編集済み: Wayne King 2014 年 7 月 23 日
gauss() is not a MathWorks' function. Have you downloaded this function from somewhere?
If so, you need to add the folder where you have placed the function on the MATLAB path.
Use addpath() or
>>pathtool
to do that.
If you have the Statistics Toolbox, you can simply use normpdf() if you want to obtain a Gaussian PDF.
x = 1:.01:7;
mu = 4.5636;
sd = 0.5969;
y = normpdf(x,mu,sd);
plot(x,y)
Or tell us what you think gauss() is going to do?

Nikola
Nikola 2014 年 7 月 23 日
I made X as 275x1 double, actually its vector with: 170 fives, 90 fours and 15 threes, and I wanna make normal ( gauss) distirbution. Im newbie to matlab... I already did this problem in excell but I have problem in matlab.

Wayne King
Wayne King 2014 年 7 月 23 日
編集済み: Wayne King 2014 年 7 月 23 日
I'll leave aside whether it is prudent to fit a normal distribution to these data.
Do you have the Statistics Toolbox installed?
If you enter
>>ver
Do you see the Statistics Toolbox listed?
If so, you can do this with your data
x = [5*ones(170,1); 4*ones(90,1); 3*ones(15,1)];
[muhat,sigmahat] = normfit(x);
You'll see those are equal to what you wrote in your post.
The above gives you the estimate mean (muhat) for the fitted normal and the estimated standard deviation.
You can obtain the PDF with:
t = 2:.01:7;
y = normpdf(t,muhat,sigmahat);
plot(t,y)
Alternatively, you can just use histfit()
histfit(x,20,'normal')

Nikola
Nikola 2014 年 7 月 23 日
Statistics Toolbox Version 7.5
histfit function gives me distribution that is far differnet than one made in excell.
but thank you very much at least i learned new way how to create variable with matrices "ones"
i used to create three vectors y1 y2 y3, one with 170 fives, one with 90 fours and one with 15 threes and that i create variable x =[y1 y2 y3]
your way looks better
  1 件のコメント
Wayne King
Wayne King 2014 年 7 月 23 日
histfit() is just scaling the PDF for plotting otherwise you would not see with your data. Look at the output of
[muhat,sigmahat] = normfit(x);
It gives you exactly the mean and standard deviation you included with your original post.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by