How to define fittype object from custom function?

1 回表示 (過去 30 日間)
Fotaras Sitof
Fotaras Sitof 2015 年 11 月 24 日
Dear all,
I'm trying to define a fittype object from the function y = fun(x,c1,c2,c3,c4,c5,c6,P), where c1,c2,c3,c4,c5,c6 are the variable fitting parameters and P is a constant struct:
ft = fittype(@(c1,c2,c3,c4,c5,c6,x) fun(x,c1,c2,c3,c4,c5,c6,P), 'independent', {'x'}, 'dependent', {'y'});
but get the following errors:
Error using fittype>iTestCustomModelEvaluation (line 730) Custom equations must produce an output vector, matrix, or array that is the same size and shape as the input data. This custom equation fails to meet that requirement:
Error in fittype>iCreateFittype (line 367) iTestCustomModelEvaluation( obj );
Error in fittype (line 324) obj = iCreateFittype( obj, varargin{:} );
The function works fine producing same size x & y data so I have no clue why defining the fittype fails.
Thanks for any help.

回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by