Error message in Non-linear fit for more than three variables

% Create an anonymous function that describes the expected relationship
% between X and Y
fun = @(b,X) b(1)*X(:,1) + b(2)*X(:,2) + b(3) * exp(b(4)*X(:,3));
% Create a data set to use for our example
% Specify beta
b = [100; 200; 3; 4];
% Create some X variables
X = rand(100,3);
% Y = fun(X)
Y = fun(b,X) + randn(100,1);
% Specify a vector of starting conditions for the solvers
b0 = [75; 300; 1; 8];
% Perform a nonlinear regression
beta = nlinfit(X,Y, fun, b0);
When I run the following script for non-linear fit ,I get this error message (Error in nlinfit (line 14) beta = nlinfit(X,Y, fun, b0);
Are there any syntax errors in the following code?

5 件のコメント

Walter Roberson
Walter Roberson 2020 年 8 月 11 日
What error message do you get? That code works without error message for me.
MOHAMED ABDULAZIM
MOHAMED ABDULAZIM 2020 年 8 月 11 日
when I run it,I get this error : Error in nlinfit (line 14) beta = nlinfit(X,Y, fun, b0);
MOHAMED ABDULAZIM
MOHAMED ABDULAZIM 2020 年 8 月 11 日
Does the presence in the anonymous function in the script make this error ? My MATLAB Program virsion is 2013a
Walter Roberson
Walter Roberson 2020 年 8 月 12 日
You named the file of code nlinfit.m and that is interfering with calling the Statistics Toolbox nlinfit() function. You need to rename your own script to something else.
MOHAMED ABDULAZIM
MOHAMED ABDULAZIM 2020 年 8 月 14 日
Thank you very much ,Walter Roberson.

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品

リリース

R2013a

タグ

質問済み:

2020 年 8 月 11 日

コメント済み:

2020 年 8 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by