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

Thread Subject:
How can I create a symbolic function that approximates numerical data?

Subject: How can I create a symbolic function that approximates numerical data?

From: Eoin

Date: 11 Feb, 2009 18:15:03

Message: 1 of 5

Hi everyone, I am wondering how can i approximate numerical data sets, for example two vectors y and x, by a symbolic function f so that y=f(x)? I've searched around but can't seem to find out if its possible. Thanks

Subject: How can I create a symbolic function that approximates numerical data?

From: Eoin

Date: 11 Feb, 2009 19:11:02

Message: 2 of 5

ah, i think i found what i need, i can use

 p = polyfit(X, Y,n);

to get coefficients of an interpolating polynomial of degree n for Y and X
and then use these coefficients to symbolically define that n degree polynomial f
as a function of some symbolic variable x

syms x
f = p(1)*x^1 + p(2)*x^2 + ......+p(n)*x^n;

Subject: How can I create a symbolic function that approximates numerical data?

From: John D'Errico

Date: 11 Feb, 2009 20:35:04

Message: 3 of 5

"Eoin " <eoinlynch86@gmail.com> wrote in message <gmv7s6$l9j$1@fred.mathworks.com>...
> ah, i think i found what i need, i can use
>
> p = polyfit(X, Y,n);
>
> to get coefficients of an interpolating polynomial of degree n for Y and X
> and then use these coefficients to symbolically define that n degree polynomial f
> as a function of some symbolic variable x
>
> syms x
> f = p(1)*x^1 + p(2)*x^2 + ......+p(n)*x^n;

My polyfitn includes a tool polyn2sym, that
will convert the result directly into a sym, or
into a sympoly from my own toolbox.

http://www.mathworks.com/matlabcentral/fileexchange/10065

John

Subject: How can I create a symbolic function that approximates numerical data?

From: Stephen

Date: 12 Feb, 2009 15:10:18

Message: 4 of 5

"Eoin " <eoinlynch86@gmail.com> wrote in message <gmv7s6$l9j$1@fred.mathworks.com>...
> ah, i think i found what i need, i can use
>
> p = polyfit(X, Y,n);
>
> to get coefficients of an interpolating polynomial of degree n for Y and X
> and then use these coefficients to symbolically define that n degree polynomial f
> as a function of some symbolic variable x
>
> syms x
> f = p(1)*x^1 + p(2)*x^2 + ......+p(n)*x^n;

Note that you can directly convert a polynomial coefficient vector to a symbolic polynomial using POLY2SYM in Symbolic Toolbox.

Subject: How can I create a symbolic function that approximates numerical data?

From: Christopher Creutzig

Date: 16 Feb, 2009 11:59:02

Message: 5 of 5

"Eoin " <eoinlynch86@gmail.com> wrote in message <gmv4j7$3as$1@fred.mathworks.com>...
> Hi everyone, I am wondering how can i approximate numerical data sets, for example two vectors y and x, by a symbolic function f so that y=f(x)? I've searched around but can't seem to find out if its possible. Thanks

feval(symengine, 'interpolate', x, y, sym('x'))

feval(symengine, 'numeric::cubicSpline', x, y)


Regards,
    Christopher

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us