Matlab built-in function not identified
9 ビュー (過去 30 日間)
古いコメントを表示
I am trying to use the function coefTest from the Statistics and Machine Learning Toolbox after calling the function I recive the error message
Undefined function or variable 'coefTest'.
I have checked that the statistics and machine learning toolbox is installed and enabled, has anybody else has an idea on how to further truble shoot this issue?
Thanks
0 件のコメント
回答 (2 件)
Bora Eryilmaz
2023 年 2 月 3 日
編集済み: Bora Eryilmaz
2023 年 2 月 3 日
coefTest is not a "function". It is a "method" of the LinearModel object/class. So, in order to call it, you need to create a linear model first. Something like this:
m = fitlm(array2table(rand(10,2)))
coefTest(m)
3 件のコメント
Bora Eryilmaz
2023 年 2 月 3 日
編集済み: Bora Eryilmaz
2023 年 2 月 3 日
Seems to be working for me and here. It probably has something to do with the creation of a LinearModel that brings the help for the coefTest() method into scope:
help coefTest
Steven Lord
2023 年 2 月 3 日
Fresh start from MATLAB, "help coefTest" shows nothing but "doc coefTest" gives doc
That's correct. Not all classes in MATLAB are loaded into memory on MATLAB startup, IIRC. If the classes aren't loaded MATLAB won't know about the methods. Constructing an instance of a class makes MATLAB load the class definition into memory and I believe help looks at what's in memory. The doc function doesn't care what's in memory.
Steven Lord
2023 年 2 月 3 日
According to a search there are several different functions named coefTest in Statistics and Machine Learning Toolbox. From a quick scan of their documentation pages I believe the reason you're unable to call the function is that each of them requires that their first input is a certain type of object. If you were to try to call them with something other than one of those specific types of objects as the first input, MATLAB would not know to call that function.
coefTest(1:10) % won't work
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!