I loaded two vectors into my workspace, plotted them versus one another, used the "basic fitting" tool on the plot, and saved the fit to my workspace. So I now have a structure named "ResourceFit" that shows up in my variable list. However, when I try to call
feval('ResourceFit', 0.17)
for example, I get
Error using feval Undefined function 'ResourceFit' for input arguments of type 'double'.
I'm an infrequent Matlab user, but I swear I've done this before....not sure where I'm going wrong.

 Respuesta aceptada

Matt J
Matt J el 1 de Jul. de 2014
Editada: Matt J el 1 de Jul. de 2014

0 votos

I assume you are talking about the feval method for fittype objects, described here
If you have the Curve Fitting Toolbox installed and the object created by the steps you describe is of type "fittype", then it should work if you omit the quotes,
feval(ResourceFit, 0.17)

4 comentarios

Matt J
Matt J el 1 de Jul. de 2014
Jeremy commented:
That may be my problem. I plotted the data, then used the fit tool that's available from the plot "tools" menu. What's saved to the workspace is a 1x1 Struct. I just went back and re-accomplished one of my fits (there are 21 of them in all) using the curve fitting tool (cftool) and built the same fit. When I saved it to the workspace, it saved as a cfit object, not a struct, and I can call it with feval as I expected.
So my question now is, is there an easy way to produce cfit objects from my other 20 struct's, or am I going to have to go through cftool for all of them?
Matt J
Matt J el 1 de Jul. de 2014
Editada: Matt J el 1 de Jul. de 2014
These are 1D polynomial fits? If so, you can just use polyval on the coefficients contained in the structure. No need for fancier stuff.
Jeremy
Jeremy el 1 de Jul. de 2014
Unfortunately no, they're splines. The plots are of cumulative density functions for empirical data, so they're very "non-smooth"....
Jeremy
Jeremy el 1 de Jul. de 2014
Your answer did lead me to a solution though!
It's painful, and I'm not sure why Matlab makes you go through this, but you can:
pp=mkpp(ResourceFit.coeff.breaks, ResourceFit.coeff.coefs)
ppval (pp, 0.17)
and get the correct answer.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 1 de Jul. de 2014

Comentada:

el 1 de Jul. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by