Curve fitting with a custom equation
Afficher commentaires plus anciens
Hi all,
I'm trying to fit a custom equation but it seems I wrote not in the correct way or somethinkg similar (I'm quite new to Matlab)...
The equation is
u+(f-u)/(1+exp((-H/1.9872)*(1/x-1/m)+(C/1.9872)*[((m/x)-1)+log(x/m)]))
and the error message claims
Fit Name: untitled fit 1
Error: Expression u+(f-u)/(1+exp((-H/1.9872)*(1/x-1/m)+(C/1.9872)*[((m/.x)-1)+log(x/m)])) is not a valid MATLAB expression, has non-scalar coefficients, or cannot be evaluated:
Error in fittype expression ==> u+(f-u)./(1+exp((-H./1.9872).*(1./x-1./m)+(C./1.9872).*[((m./.x)-1)+log(x./m)]))
??? Invalid use of operator.
Do you have suggestions?
Thanks
Marco
Réponses (2)
Torsten
le 10 Oct 2025
0 votes
Only round brackets are allowed in your expression. But maybe there are additional problems.
If the code does not work after replacing [ ] by ( ), you should post your MATLAB code for inspection.
6 commentaires
Marco Sette
le 10 Oct 2025
Torsten
le 10 Oct 2025
Follow the instructions given here:
Especially:
- On the Curve Fitter tab, in the Export section, click Export and select Generate Code.The Curve Fitter app generates code from your session and displays the file in the MATLAB Editor. The file includes the currently selected fit in your session and its opened plots. The file captures the following information:
- Name of the fit and its variables
- Fit settings and options
- Plots
- Curve or surface fitting object and the function used to create the fit:
- cfit or sfit object representing the fit
- A structure with goodness-of-fit information
2. Save the file.
Image Analyst
le 10 Oct 2025
You could help us help you by attaching the data you are using to train the fit.
Marco Sette
le 10 Oct 2025
Modifié(e) : Marco Sette
le 10 Oct 2025
Torsten
le 10 Oct 2025
In your fittype expression, there is another error:
m/.x
should be replaced by
m./x
or at least
m/x
Marco Sette
le 11 Oct 2025
0 votes
Catégories
En savoir plus sur Linear and Nonlinear Regression dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!