Undefined function for input arguments of type 'double'

311 ビュー (過去 30 日間)
Stefania
Stefania 2014 年 11 月 10 日
コメント済み: Gizem Deniz Akkas 2022 年 3 月 26 日
I have this set of data
x=[0:0.01:1];
y=4- 3*x + sin(x*6*pi) + rand(1,101)/8;
plot(x,y,'ko','MarkerFaceColor','k');
and want to do a fit using fminsearch
hold on
b0=[2,-2,2,5];
b=fminsearch(@(b) doamne(b,x,y), b0);
yfit= b(1)+ b(2)*x + b(3)*sin(x*pi*b(4));
plot(x,yfit, '-b')
hold off
where
function d2=doamne(b,x,y)
c2=y- (b(1)+ b(2)*x)
d2=sum(c2.^2)
but I keep getting this error: "Undefined function 'doamne' for input arguments of type 'double'." I double checked that all my files are in the working folder and that the working folder is in the path list but the error persists.

採用された回答

Geoff Hayes
Geoff Hayes 2014 年 11 月 10 日
Stefania - in the Command Window, type
which doamne -all
to find the path to your doamne function. Perhaps you have named the m file for this function incorrectly, and so it cannot be found.
I was able to take the doamne function and copy and paste its code into a file named doamne.m and then could run the remainder of your code without error.
  5 件のコメント
Jozef Duda
Jozef Duda 2017 年 3 月 21 日
I've also met similar error when clearing workspace from data acquired with Data Acquisition Toolbox. The error function was 'stop'. The solution was to find the 'stop' function, copy it in to the new file and name it stop.m and save it in current folder. After that operation the error information stopped to appear in the command window. Really thanks for this answear.
sam Boadi
sam Boadi 2018 年 8 月 24 日
Possibly, you are using a different function name to call another function. Check to see that the name you are using to call the function is the same as the function name. I think this should also help

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

その他の回答 (1 件)

Jithin Nambiar J
Jithin Nambiar J 2021 年 4 月 10 日
It sometimes gives you this error if you don't have the right toolboxes installed for the certain function.
If a particular function is causing an error. Try typing
help functionName
If this results in like a certain toolbox is required for this function to work. Just click on the hyperlink or underlined link which is given in the terminal.
It will direct you to the appropriate package. Make sure you save any programs. Since installing the packages requires MATLAB to restart.
Cheers !!

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by