Error: Unable to use a value of type 'fittype' as an index.

4 vues (au cours des 30 derniers jours)
Claudia Dessi
Claudia Dessi le 27 Nov 2018
Modifié(e) : Prinkle Sharma le 10 Fév 2019
Hi there,
I am struggling to understand how to solve an error occurring when using a customized non-linear fit function with Matlab.
Here is the function I need to employ:
CAO = 0.02;
expFIT = fittype(@(a, b, CD) a*((CA0+CD+b)-sqrt((CA0+CD+b).^2-4*CA0*CD)) ,'independent',{'CD'});
Up to here, no error.
Then, when it comes to perform the actual fit I get the following statement: '
Unable to use a value of type 'fittype' as an index'.
And it goes to the line with the fit command:
FIT = fit(CD, Abs, expFIT,'Robust','on');
Thank you in advance for any feedback!

Réponse acceptée

Steven Lord
Steven Lord le 27 Nov 2018
Rename the variable you created with the name fit.
  3 commentaires
Steven Lord
Steven Lord le 27 Nov 2018
Did you clear the variable named fit after you executed the command AbsFIT = fit; (or whatever similar command you used?)
Claudia Dessi
Claudia Dessi le 27 Nov 2018
No, I did not.
I did it this morning and now it works. It is curious though that FIT name for another fit command in another code was just fine, and I thought that capital letters may not create confusion to the program.
thanks!

Connectez-vous pour commenter.

Plus de réponses (1)

Prinkle Sharma
Prinkle Sharma le 10 Fév 2019
Modifié(e) : Prinkle Sharma le 10 Fév 2019
While compiling:
[~,score_knn] = resubPredict(KNNModel);
labels = predict(KNNModel,test(:,1:9));
I'm experiencing similar error: "Unable to use a value of type 'ClassificationKNN' as an index." with the line below
[Xknn, Yknn, Tknn, AUCknn] = perfcurve(labels,score_knn(:,KNNModel),'true');
Can someone help me with this please ?

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by