How to save a workspace with fittypes that use anonymous functions?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am defining fittypes that refer to an anonymous functions. Afterwards I fit the model and saved the workspace. Here is a minimalistic example:
testfunc = @(params1, params2, x) params1*x + params2*x.^2;
testfittype = fittype(@(params1, params2, x) 2*testfunc(params1, params2, x));
x = [1;2;3];
y = [1;5;20];
[model, gof, output] = fit(x, y, testfittype);
Now whenever I close matlab and load the saved workspace I get warnings that seem to stem from the anonymous function definition inside the fittype.
Warning: Could not find appropriate function on path loading function handle
My question is how can I get around those errors? I know that I could just avoid putting an anonyous function inside a fittype definition but since my real examples are quite long I would like to avoid that.
5 Kommentare
Antworten (1)
SACHIN KHANDELWAL
am 16 Apr. 2024
Hi @Sophie
It seems you're experiencing some difficulties while attempting to save a workspace that includes "fittype" function.
To help with this, I'd kindly suggest using MATLAB's "save" function to preserve your workspace in a '.MAT' file. Once saved, you can easily retrieve your workspace at any time by employing the 'load' function in MATLAB.
I tried it on my end, and it is working as expected.
Thanks!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!