I keep getting error for undefined function or variable, and I am not sure how to fix it

3 ビュー (過去 30 日間)
Naveed Hossain
Naveed Hossain 2018 年 9 月 3 日
コメント済み: Naveed Hossain 2018 年 9 月 3 日
I am getting error on line 5 for the code below. My Y1 and Dmge is already in the workspace, but they keep saying that my 'x' is an undefined variable or function. Same for my 'y'.
function E=goemp_fit(x0)
A = x0(1); B=x0(2); C=x0(3);
x=Y1;
y = Dmge;
E = sum((A*exp(-exp(-B*(x-C)))-y).^2);

採用された回答

Greg
Greg 2018 年 9 月 3 日
編集済み: Greg 2018 年 9 月 3 日
Post the full error text. I'm pretty sure it doesn't say line 5.
Y1 and Dmge might be defined in your base workspace, but goemp_fit is a function. Read the documentation of function workspaces. In short, they have no acess to the base workspace, so Y1 and Dmge are unknown, hence the error (on line 3, not 5).
  1 件のコメント
Naveed Hossain
Naveed Hossain 2018 年 9 月 3 日
That explains everything. Thanks!!!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by