Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

How to construct an anonymous function from the result of the fit command?

Asked by Federico on 26 Dec 2013
Latest activity Commented on by Federico on 26 Dec 2013

Hello,

I am trying to do some data fitting with a data set that resembles an air bubble when plotted. I am trying to obtain a function that defines the surface of the bubble. The following result perfectly fits the the profile.

f=fit(x(:,2),-y(:,1),'smoothingspline')
plot(f,x(:,2),-y(:,1)

Now, I would like to create an anonymous function. How can I accomplish this?

Thank you.

0 Comments

Federico

Products

No products are associated with this question.

2 Answers

Answer by Matt J on 26 Dec 2013
Edited by Matt J on 26 Dec 2013
Accepted answer
 anonf=@(x) f(x)

1 Comment

Federico on 26 Dec 2013

Wow, that was easy enough. Thank you very much!

Matt J
Answer by The Matlab Spot on 26 Dec 2013
Edited by The Matlab Spot on 26 Dec 2013

Refer Anonymous Functions for further details

0 Comments

The Matlab Spot

Contact us