How can I use fitdist function

4 ビュー (過去 30 日間)
Juergen Maier
Juergen Maier 2018 年 3 月 6 日
コメント済み: Juergen Maier 2025 年 1 月 30 日
Hello,
I tried to use the function fitdist. The only result is an error:
Undefined function 'fitdist' for input arguments of type 'double'.
Error in FitaNormalDistributiontoDataExample (line 13) pd = fitdist(x,'Normal')
This was the result of running the code from help file: C:\Users\...\Documents\MATLAB\Examples\FitaNormalDistributiontoDataExample\FitaNormalDistributiontoDataExample.m
%%Fit a Normal Distribution to Data
% Copyright 2015 The MathWorks, Inc.
Load the sample data. Create a vector containing the patients' weight data.
load hospital
x = hospital.Weight;
Create a normal distribution object by fitting it to the data.
pd = fitdist(x,'Normal')
Plot the pdf of the distribution.
x_values = 50:1:250;
y = pdf(pd,x_values);
plot(x_values,y,'LineWidth',2)
What is wrong here?

回答 (1 件)

Jaimin
Jaimin 2025 年 1 月 28 日
The error message you are encountering suggests that MATLAB does not recognize the “fitdist” function. This could be due to a few reasons:
  • The “fitdist” function is part of the Statistics and Machine Learning Toolbox. Make sure that this toolbox is installed and licensed on your MATLAB environment.
  • Ensure that your MATLAB path is set correctly and that you are using a version of MATLAB that supports the “fitdist” function.
  • It is possible that another function or script named “fitdist” is shadowing the built-in function. Check your current directory and the MATLAB path for any files named “fitdist.m”.
Here's how you can troubleshoot and resolve the issue:
  • Go to the MATLAB “Command Window” and type “ver”. This will list all installed toolboxes. Look for "Statistics and Machine Learning Toolbox" in the list.
  • Use the which command to check if the function is recognized: “which fitdist”.
For more information kindly refer following MathWorks documentation.
I hope this will be helpful.
  1 件のコメント
Juergen Maier
Juergen Maier 2025 年 1 月 30 日
The answer is a little bit late ;-)

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by