How can I use fitdist function

조회 수: 8 (최근 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