MATLAB Newsgroup

hi, i am looking for a way to replicate the exact values that i get from a variable in matlab.

i have a variable, fitmodel fm1, with the coefficients of the polynomial that fit the data. if i use the symbolic values of these coefficients in a consequent equation i get different result than if i use the numeric values of the coefficients that are showed for these variables.

supposing the case:

Linear model Poly9:

fm1(x) = p1*x^9 + p2*x^8 + p3*x^7 + p4*x^6 +

p5*x^5 + p6*x^4 + p7*x^3 + p8*x^2 + p9*x + p10

Coefficients (with 95% confidence bounds):

p1 = 8.32e-007 (8.257e-007, 8.383e-007)

p2 = -5.217e-005 (-5.25e-005, -5.185e-005)

p3 = 0.001308 (0.001301, 0.001315)

p4 = -0.01684 (-0.01693, -0.01676)

p5 = 0.1189 (0.1183, 0.1195)

p6 = -0.4585 (-0.461, -0.456)

p7 = 0.9485 (0.9422, 0.9547)

p8 = -1.185 (-1.193, -1.176)

p9 = 1.063 (1.058, 1.068)

p10 = -0.5639 (-0.565, -0.5629)

i get different result if i use fm1.p1 than if i use 8.32/10^7.

nonetheless i need to use the numerical data, not the variable itself; so i'd like to ask you about how can i extract the exact value of the variables?

thank you so very much!

Orchy

"Orchid Bee" <orchidbee08@yahoo.com> wrote in message <gjbb62$7dg$1@fred.mathworks.com>...

> hi, i am looking for a way to replicate the exact values that i get from a variable in matlab.

> i have a variable, fitmodel fm1, with the coefficients of the polynomial that fit the data. if i use the symbolic values of these coefficients in a consequent equation i get different result than if i use the numeric values of the coefficients that are showed for these variables.

> supposing the case:

> Linear model Poly9:

> fm1(x) = p1*x^9 + p2*x^8 + p3*x^7 + p4*x^6 +

> p5*x^5 + p6*x^4 + p7*x^3 + p8*x^2 + p9*x + p10

> Coefficients (with 95% confidence bounds):

> p1 = 8.32e-007 (8.257e-007, 8.383e-007)

> p2 = -5.217e-005 (-5.25e-005, -5.185e-005)

> p3 = 0.001308 (0.001301, 0.001315)

> p4 = -0.01684 (-0.01693, -0.01676)

> p5 = 0.1189 (0.1183, 0.1195)

> p6 = -0.4585 (-0.461, -0.456)

> p7 = 0.9485 (0.9422, 0.9547)

> p8 = -1.185 (-1.193, -1.176)

> p9 = 1.063 (1.058, 1.068)

> p10 = -0.5639 (-0.565, -0.5629)

>

> i get different result if i use fm1.p1 than if i use 8.32/10^7.

> nonetheless i need to use the numerical data, not the variable itself; so i'd like to ask you about how can i extract the exact value of the variables?

> thank you so very much!

>

> Orchy

You haven't stated what kind of fit to the data you are striving for. If you have exactly ten data points, in general an exact unique fit is possible, but if there are more, then the coefficients you obtain will depend on what sort of fit you want. This is true symbolically as well as numerically. For example, a least squares fit can be obtained using the matlab backslash operator '\' and the result of that is exact for a symbolic solution and numerically the accuracy can be to approximately one part in 1e16.

Roger Stafford

"Orchid Bee" <orchidbee08@yahoo.com> wrote in message <gjbb62$7dg$1@fred.mathworks.com>...

> hi, i am looking for a way to replicate the exact values that i get from a variable in matlab.

> i have a variable, fitmodel fm1, with the coefficients of the polynomial that fit the data. if i use the symbolic values of these coefficients in a consequent equation i get different result than if i use the numeric values of the coefficients that are showed for these variables.

> supposing the case:

> Linear model Poly9:

> fm1(x) = p1*x^9 + p2*x^8 + p3*x^7 + p4*x^6 +

> p5*x^5 + p6*x^4 + p7*x^3 + p8*x^2 + p9*x + p10

> Coefficients (with 95% confidence bounds):

> p1 = 8.32e-007 (8.257e-007, 8.383e-007)

> p2 = -5.217e-005 (-5.25e-005, -5.185e-005)

> p3 = 0.001308 (0.001301, 0.001315)

> p4 = -0.01684 (-0.01693, -0.01676)

> p5 = 0.1189 (0.1183, 0.1195)

> p6 = -0.4585 (-0.461, -0.456)

> p7 = 0.9485 (0.9422, 0.9547)

> p8 = -1.185 (-1.193, -1.176)

> p9 = 1.063 (1.058, 1.068)

> p10 = -0.5639 (-0.565, -0.5629)

>

> i get different result if i use fm1.p1 than if i use 8.32/10^7.

> nonetheless i need to use the numerical data, not the variable itself; so i'd like to ask you about how can i extract the exact value of the variables?

> thank you so very much!

>

> Orchy

% If I understand, try

doc format

fm1.p1

format long

fm1.p1

% You will see many more digits displayed.

% By default (with format short), MATLAB displays only about 4 significant digits.

% Using format long dispalys about 3 times as many significant digits.

% format affects ONLY how the numbers are DISPLAYED.

% Not how MATLAB computes or stores the numbers.

% Or use the File -> Preferences -> Command Window option

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gjbcj3$2j5$1@fred.mathworks.com>...

> "Orchid Bee" <orchidbee08@yahoo.com> wrote in message <gjbb62$7dg$1@fred.mathworks.com>...

> > hi, i am looking for a way to replicate the exact values that i get from a variable in matlab.

> > i have a variable, fitmodel fm1, with the coefficients of the polynomial that fit the data. if i use the symbolic values of these coefficients in a consequent equation i get different result than if i use the numeric values of the coefficients that are showed for these variables.

> > supposing the case:

> > Linear model Poly9:

> > fm1(x) = p1*x^9 + p2*x^8 + p3*x^7 + p4*x^6 +

> > p5*x^5 + p6*x^4 + p7*x^3 + p8*x^2 + p9*x + p10

> > Coefficients (with 95% confidence bounds):

> > p1 = 8.32e-007 (8.257e-007, 8.383e-007)

> > p2 = -5.217e-005 (-5.25e-005, -5.185e-005)

> > p3 = 0.001308 (0.001301, 0.001315)

> > p4 = -0.01684 (-0.01693, -0.01676)

> > p5 = 0.1189 (0.1183, 0.1195)

> > p6 = -0.4585 (-0.461, -0.456)

> > p7 = 0.9485 (0.9422, 0.9547)

> > p8 = -1.185 (-1.193, -1.176)

> > p9 = 1.063 (1.058, 1.068)

> > p10 = -0.5639 (-0.565, -0.5629)

> >

> > i get different result if i use fm1.p1 than if i use 8.32/10^7.

> > nonetheless i need to use the numerical data, not the variable itself; so i'd like to ask you about how can i extract the exact value of the variables?

> > thank you so very much!

> >

> > Orchy

>

> You haven't stated what kind of fit to the data you are striving for. If you have exactly ten data points, in general an exact unique fit is possible, but if there are more, then the coefficients you obtain will depend on what sort of fit you want. This is true symbolically as well as numerically. For example, a least squares fit can be obtained using the matlab backslash operator '\' and the result of that is exact for a symbolic solution and numerically the accuracy can be to approximately one part in 1e16.

>

> Roger Stafford

- Hi, Roger.

i'm not sure i get your point. is the type of fit relevant for my issue?

i use polynomial of 9 degree to fit my data whose size varies.

i used the data to obtain the fit function using 9 degree polynomial. further, i want to make use of the polynomial i get.

instead of using the expression

pf = fm1.p1.*myx^9+fm1.p2.*myx^8+ ...

i want to use

pf = 8.32/(10^7)*myx^9-5.217/(10^5)*myx^8+...

my problem appears as the second pf is different than the first pf. and more certainly that's because fm1.p1 displays a rather approximated value of the first coefficient, so , when i copy it as it is displayed on the screen, i don't get the right coefficient, but that certain approximation. i don't know how to extract the exact numerical value from fm1.p1(, and other similar coefficients).

Orchy

"Orchid Bee" <orchidbee08@yahoo.com> wrote in message <gjbdu6$ocp$1@fred.mathworks.com>...

> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gjbcj3$2j5$1@fred.mathworks.com>...

> > "Orchid Bee" <orchidbee08@yahoo.com> wrote in message <gjbb62$7dg$1@fred.mathworks.com>...

> > > hi, i am looking for a way to replicate the exact values that i get from a variable in matlab.

> > > i have a variable, fitmodel fm1, with the coefficients of the polynomial that fit the data. if i use the symbolic values of these coefficients in a consequent equation i get different result than if i use the numeric values of the coefficients that are showed for these variables.

> > > supposing the case:

> > > Linear model Poly9:

> > > fm1(x) = p1*x^9 + p2*x^8 + p3*x^7 + p4*x^6 +

> > > p5*x^5 + p6*x^4 + p7*x^3 + p8*x^2 + p9*x + p10

> > > Coefficients (with 95% confidence bounds):

> > > p1 = 8.32e-007 (8.257e-007, 8.383e-007)

> > > p2 = -5.217e-005 (-5.25e-005, -5.185e-005)

> > > p3 = 0.001308 (0.001301, 0.001315)

> > > p4 = -0.01684 (-0.01693, -0.01676)

> > > p5 = 0.1189 (0.1183, 0.1195)

> > > p6 = -0.4585 (-0.461, -0.456)

> > > p7 = 0.9485 (0.9422, 0.9547)

> > > p8 = -1.185 (-1.193, -1.176)

> > > p9 = 1.063 (1.058, 1.068)

> > > p10 = -0.5639 (-0.565, -0.5629)

> > >

> > > i get different result if i use fm1.p1 than if i use 8.32/10^7.

> > > nonetheless i need to use the numerical data, not the variable itself; so i'd like to ask you about how can i extract the exact value of the variables?

> > > thank you so very much!

> > >

> > > Orchy

> >

> > You haven't stated what kind of fit to the data you are striving for. If you have exactly ten data points, in general an exact unique fit is possible, but if there are more, then the coefficients you obtain will depend on what sort of fit you want. This is true symbolically as well as numerically. For example, a least squares fit can be obtained using the matlab backslash operator '\' and the result of that is exact for a symbolic solution and numerically the accuracy can be to approximately one part in 1e16.

> >

> > Roger Stafford

>

> - Hi, Roger.

> i'm not sure i get your point. is the type of fit relevant for my issue?

> i use polynomial of 9 degree to fit my data whose size varies.

> i used the data to obtain the fit function using 9 degree polynomial. further, i want to make use of the polynomial i get.

> instead of using the expression

> pf = fm1.p1.*myx^9+fm1.p2.*myx^8+ ...

> i want to use

> pf = 8.32/(10^7)*myx^9-5.217/(10^5)*myx^8+...

>

> my problem appears as the second pf is different than the first pf. and more certainly that's because fm1.p1 displays a rather approximated value of the first coefficient, so , when i copy it as it is displayed on the screen, i don't get the right coefficient, but that certain approximation. i don't know how to extract the exact numerical value from fm1.p1(, and other similar coefficients).

> Orchy

Orchy,

It looks like your are talking about the output that comes out for the "fit" function from the Curve Fitting Toolbox.

fm1.p1, fm1.p2, etc are the accurate coefficients. What's displayed on the screen will not be the exact because of the precision for the display (it's merely for display). So ideally, you should use the actual values from the fit result (fm1.p1, etc).

My question is WHY do you need to represent it with the actual numbers? I can think of many reasons why you should NOT do that, one of which is the accuracy problem you are encountering. Another reason is that you are hard-coding the results, so if you were to reuse your code on a different data set, you have to re-write your code. Is there a reason you cannot use the variable form (the first expression you showed)?

If you can answer me these questions, then we can try to address your issue.

jiro

"Jiro Doke" <jiro.doke@mathworks.com> wrote in message <gjbgeq$sej$1@fred.mathworks.com>...

> "Orchid Bee" <orchidbee08@yahoo.com> wrote in message <gjbdu6$ocp$1@fred.mathworks.com>...

> > "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gjbcj3$2j5$1@fred.mathworks.com>...

> > > "Orchid Bee" <orchidbee08@yahoo.com> wrote in message <gjbb62$7dg$1@fred.mathworks.com>...

> > > > hi, i am looking for a way to replicate the exact values that i get from a variable in matlab.

> > > > i have a variable, fitmodel fm1, with the coefficients of the polynomial that fit the data. if i use the symbolic values of these coefficients in a consequent equation i get different result than if i use the numeric values of the coefficients that are showed for these variables.

> > > > supposing the case:

> > > > Linear model Poly9:

> > > > fm1(x) = p1*x^9 + p2*x^8 + p3*x^7 + p4*x^6 +

> > > > p5*x^5 + p6*x^4 + p7*x^3 + p8*x^2 + p9*x + p10

> > > > Coefficients (with 95% confidence bounds):

> > > > p1 = 8.32e-007 (8.257e-007, 8.383e-007)

> > > > p2 = -5.217e-005 (-5.25e-005, -5.185e-005)

> > > > p3 = 0.001308 (0.001301, 0.001315)

> > > > p4 = -0.01684 (-0.01693, -0.01676)

> > > > p5 = 0.1189 (0.1183, 0.1195)

> > > > p6 = -0.4585 (-0.461, -0.456)

> > > > p7 = 0.9485 (0.9422, 0.9547)

> > > > p8 = -1.185 (-1.193, -1.176)

> > > > p9 = 1.063 (1.058, 1.068)

> > > > p10 = -0.5639 (-0.565, -0.5629)

> > > >

> > > > i get different result if i use fm1.p1 than if i use 8.32/10^7.

> > > > nonetheless i need to use the numerical data, not the variable itself; so i'd like to ask you about how can i extract the exact value of the variables?

> > > > thank you so very much!

> > > >

> > > > Orchy

> > >

> > > You haven't stated what kind of fit to the data you are striving for. If you have exactly ten data points, in general an exact unique fit is possible, but if there are more, then the coefficients you obtain will depend on what sort of fit you want. This is true symbolically as well as numerically. For example, a least squares fit can be obtained using the matlab backslash operator '\' and the result of that is exact for a symbolic solution and numerically the accuracy can be to approximately one part in 1e16.

> > >

> > > Roger Stafford

> >

> > - Hi, Roger.

> > i'm not sure i get your point. is the type of fit relevant for my issue?

> > i use polynomial of 9 degree to fit my data whose size varies.

> > i used the data to obtain the fit function using 9 degree polynomial. further, i want to make use of the polynomial i get.

> > instead of using the expression

> > pf = fm1.p1.*myx^9+fm1.p2.*myx^8+ ...

> > i want to use

> > pf = 8.32/(10^7)*myx^9-5.217/(10^5)*myx^8+...

> >

> > my problem appears as the second pf is different than the first pf. and more certainly that's because fm1.p1 displays a rather approximated value of the first coefficient, so , when i copy it as it is displayed on the screen, i don't get the right coefficient, but that certain approximation. i don't know how to extract the exact numerical value from fm1.p1(, and other similar coefficients).

> > Orchy

>

> Orchy,

>

> It looks like your are talking about the output that comes out for the "fit" function from the Curve Fitting Toolbox.

>

> fm1.p1, fm1.p2, etc are the accurate coefficients. What's displayed on the screen will not be the exact because of the precision for the display (it's merely for display). So ideally, you should use the actual values from the fit result (fm1.p1, etc).

>

> My question is WHY do you need to represent it with the actual numbers? I can think of many reasons why you should NOT do that, one of which is the accuracy problem you are encountering. Another reason is that you are hard-coding the results, so if you were to reuse your code on a different data set, you have to re-write your code. Is there a reason you cannot use the variable form (the first expression you showed)?

>

> If you can answer me these questions, then we can try to address your issue.

>

> jiro

hi Jiro,

yes, i am using the result from the Curve Fitting Toolbox . and yes, i am encountering the first issue, but not the second one.

my goal here was to find a function with a particular property. to have that property , i knew i could come up with a sort of sinusoidal combination, however i needed to describe the function by polynomial coefficients, for some code reuse reasons. therefore, i generated data with some sinusoidal function, used curve fitting tool to have a polynomial description. now, rather than doing the same procedure everytime just to get those variables and used them , i wanted to simplify the problem by only having those numerical values in the expression of the function i am hunting. moreover, the expression has to be written eventually in C code, and there it's impossible to use any matlab function.

so, this is the brief of the rationale.

as advised above, i used 'format long' command to get more accurate values. the result now is ok, but it takes a great while to compute the values of the function, probably due to those long accurate numbers?

but i suppose i can't avoid this.

still i wonder why it takes longer time to compute

pf = 8.32/(10^7)*myx^9-5.217/(10^5)*myx^8+...

than it takes to compute

pf = fm1.p1.*myx^9+fm1.p2.*myx^8+ ...

even if at the moment the numerical coefficients have the same accuracy as the symbolic ones.

thanks a lot for assistance,

Orchy

"Orchid Bee" <orchidbee08@yahoo.com> wrote in message <gjbhvh$9h$1@fred.mathworks.com>...

> "Jiro Doke" <jiro.doke@mathworks.com> wrote in message <gjbgeq$sej$1@fred.mathworks.com>...

> > "Orchid Bee" <orchidbee08@yahoo.com> wrote in message <gjbdu6$ocp$1@fred.mathworks.com>...

> > > "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gjbcj3$2j5$1@fred.mathworks.com>...

> > > > "Orchid Bee" <orchidbee08@yahoo.com> wrote in message <gjbb62$7dg$1@fred.mathworks.com>...

> > > > > hi, i am looking for a way to replicate the exact values that i get from a variable in matlab.

> > > > > i have a variable, fitmodel fm1, with the coefficients of the polynomial that fit the data. if i use the symbolic values of these coefficients in a consequent equation i get different result than if i use the numeric values of the coefficients that are showed for these variables.

> > > > > supposing the case:

> > > > > Linear model Poly9:

> > > > > fm1(x) = p1*x^9 + p2*x^8 + p3*x^7 + p4*x^6 +

> > > > > p5*x^5 + p6*x^4 + p7*x^3 + p8*x^2 + p9*x + p10

> > > > > Coefficients (with 95% confidence bounds):

> > > > > p1 = 8.32e-007 (8.257e-007, 8.383e-007)

> > > > > p2 = -5.217e-005 (-5.25e-005, -5.185e-005)

> > > > > p3 = 0.001308 (0.001301, 0.001315)

> > > > > p4 = -0.01684 (-0.01693, -0.01676)

> > > > > p5 = 0.1189 (0.1183, 0.1195)

> > > > > p6 = -0.4585 (-0.461, -0.456)

> > > > > p7 = 0.9485 (0.9422, 0.9547)

> > > > > p8 = -1.185 (-1.193, -1.176)

> > > > > p9 = 1.063 (1.058, 1.068)

> > > > > p10 = -0.5639 (-0.565, -0.5629)

> > > > >

> > > > > i get different result if i use fm1.p1 than if i use 8.32/10^7.

> > > > > nonetheless i need to use the numerical data, not the variable itself; so i'd like to ask you about how can i extract the exact value of the variables?

> > > > > thank you so very much!

> > > > >

> > > > > Orchy

> > > >

> > > > You haven't stated what kind of fit to the data you are striving for. If you have exactly ten data points, in general an exact unique fit is possible, but if there are more, then the coefficients you obtain will depend on what sort of fit you want. This is true symbolically as well as numerically. For example, a least squares fit can be obtained using the matlab backslash operator '\' and the result of that is exact for a symbolic solution and numerically the accuracy can be to approximately one part in 1e16.

> > > >

> > > > Roger Stafford

> > >

> > > - Hi, Roger.

> > > i'm not sure i get your point. is the type of fit relevant for my issue?

> > > i use polynomial of 9 degree to fit my data whose size varies.

> > > i used the data to obtain the fit function using 9 degree polynomial. further, i want to make use of the polynomial i get.

> > > instead of using the expression

> > > pf = fm1.p1.*myx^9+fm1.p2.*myx^8+ ...

> > > i want to use

> > > pf = 8.32/(10^7)*myx^9-5.217/(10^5)*myx^8+...

> > >

> > > my problem appears as the second pf is different than the first pf. and more certainly that's because fm1.p1 displays a rather approximated value of the first coefficient, so , when i copy it as it is displayed on the screen, i don't get the right coefficient, but that certain approximation. i don't know how to extract the exact numerical value from fm1.p1(, and other similar coefficients).

> > > Orchy

> >

> > Orchy,

> >

> > It looks like your are talking about the output that comes out for the "fit" function from the Curve Fitting Toolbox.

> >

> > fm1.p1, fm1.p2, etc are the accurate coefficients. What's displayed on the screen will not be the exact because of the precision for the display (it's merely for display). So ideally, you should use the actual values from the fit result (fm1.p1, etc).

> >

> > My question is WHY do you need to represent it with the actual numbers? I can think of many reasons why you should NOT do that, one of which is the accuracy problem you are encountering. Another reason is that you are hard-coding the results, so if you were to reuse your code on a different data set, you have to re-write your code. Is there a reason you cannot use the variable form (the first expression you showed)?

> >

> > If you can answer me these questions, then we can try to address your issue.

> >

> > jiro

>

> hi Jiro,

> yes, i am using the result from the Curve Fitting Toolbox . and yes, i am encountering the first issue, but not the second one.

> my goal here was to find a function with a particular property. to have that property , i knew i could come up with a sort of sinusoidal combination, however i needed to describe the function by polynomial coefficients, for some code reuse reasons. therefore, i generated data with some sinusoidal function, used curve fitting tool to have a polynomial description. now, rather than doing the same procedure everytime just to get those variables and used them , i wanted to simplify the problem by only having those numerical values in the expression of the function i am hunting. moreover, the expression has to be written eventually in C code, and there it's impossible to use any matlab function.

> so, this is the brief of the rationale.

>

> as advised above, i used 'format long' command to get more accurate values. the result now is ok, but it takes a great while to compute the values of the function, probably due to those long accurate numbers?

> but i suppose i can't avoid this.

> still i wonder why it takes longer time to compute

> pf = 8.32/(10^7)*myx^9-5.217/(10^5)*myx^8+...

> than it takes to compute

> pf = fm1.p1.*myx^9+fm1.p2.*myx^8+ ...

> even if at the moment the numerical coefficients have the same accuracy as the symbolic ones.

>

> thanks a lot for assistance,

> Orchy

I doubt that the increase in time (how much?) is due to the "long accurate numbers". It probably has more to do with how the MATLAB parser works when it reads in an m-file.

In the second case it simply retrieves the fm1.p1, etc. values from storage and uses it.

In the first case, my guess is it does something like set a temp1 variable to 8.32. Then set a second temp2 variable to 10^7. Then divide the two and put that result in temp3. Then retrieve temp3 as fm1.p1 use it from there as in the second case. And you have 10 of these coefficients, right?

But again, it depends on the specifics of the MATLAB parser, I could be wrong!

"Orchid Bee" <orchidbee08@yahoo.com> wrote in message <gjbhvh$9h$1@fred.mathworks.com>...

> hi Jiro,

> yes, i am using the result from the Curve Fitting Toolbox . and yes, i am encountering the first issue, but not the second one.

> my goal here was to find a function with a particular property. to have that property , i knew i could come up with a sort of sinusoidal combination, however i needed to describe the function by polynomial coefficients, for some code reuse reasons. therefore, i generated data with some sinusoidal function, used curve fitting tool to have a polynomial description. now, rather than doing the same procedure everytime just to get those variables and used them , i wanted to simplify the problem by only having those numerical values in the expression of the function i am hunting. moreover, the expression has to be written eventually in C code, and there it's impossible to use any matlab function.

> so, this is the brief of the rationale.

>

> as advised above, i used 'format long' command to get more accurate values. the result now is ok, but it takes a great while to compute the values of the function, probably due to those long accurate numbers?

> but i suppose i can't avoid this.

> still i wonder why it takes longer time to compute

> pf = 8.32/(10^7)*myx^9-5.217/(10^5)*myx^8+...

> than it takes to compute

> pf = fm1.p1.*myx^9+fm1.p2.*myx^8+ ...

> even if at the moment the numerical coefficients have the same accuracy as the symbolic ones.

>

> thanks a lot for assistance,

> Orchy

Hi Orchy,

You could always save the fit result (fm1) in a MAT file, which could be loaded into your session quickly whenever you need it. Also, you can evaluate the function at an arbitrary point just by typing:

pf = fm1(myx)

The longer computation time has nothing to do with the precision. The difference is that in your first case, you are performing 2 computations per coefficient: ^ and /. You should use scientific notation, e.g 1e-7. Take a look at this:

>> tic;for ii = 1:10000000,a=3e-7;end;toc

Elapsed time is 0.036858 seconds.

>> tic;for ii = 1:10000000,b=3/(10^7);end;toc

Elapsed time is 2.888624 seconds.

The part about "write in C code" may make it a bit tricky. This is a bit off-topic from this thread, but depending on what you want, there are some options. If you just want to deploy MATLAB functionality to be used in C, you can use the MATLAB Compiler to create a shared library (you won't get C code). If you really want C code, you can look at Embedded MATLAB, which is a subset of the MATLAB language (not Toolbox) that can be converted to C (requires Real-Time Workshop). In your case, if you're simply looking at a polynomial fit, you can just use POLYFIT (and POLYVAL) from MATLAB, instead of FIT from the Curve Fitting Toolbox:

>> x = 1:10;

>> y = rand(1,10);

>> p = polyfit(x,y,5) % 5-th order polynomial

p =

-0.0017 0.0522 -0.5745 2.8134 -5.9002 4.5816

>> newY = polyval(p, [1.3, 5.7, 9.5])

newY =

0.5465 0.6208 0.5614

You can think of your watch list as threads that you have bookmarked.

You can add tags, authors, threads, and even search results to your watch list. This way you can easily keep track of topics that you're interested in. To view your watch list, click on the "My Newsreader" link.

To add items to your watch list, click the "add to watch list" link at the bottom of any page.

To add search criteria to your watch list, search for the desired term in the search box. Click on the "Add this search to my watch list" link on the search results page.

You can also add a tag to your watch list by searching for the tag with the directive "tag:tag_name" where tag_name is the name of the tag you would like to watch.

To add an author to your watch list, go to the author's profile page and click on the "Add this author to my watch list" link at the top of the page. You can also add an author to your watch list by going to a thread that the author has posted to and clicking on the "Add this author to my watch list" link. You will be notified whenever the author makes a post.

To add a thread to your watch list, go to the thread page and click the "Add this thread to my watch list" link at the top of the page.

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.

The newsgroups are a worldwide forum that is open to everyone. Newsgroups are used to discuss a huge range of topics, make announcements, and trade files.

Discussions are threaded, or grouped in a way that allows you to read a posted message and all of its replies in chronological order. This makes it easy to follow the thread of the conversation, and to see what’s already been said before you post your own reply or make a new posting.

Newsgroup content is distributed by servers hosted by various organizations on the Internet. Messages are exchanged and managed using open-standard protocols. No single entity “owns” the newsgroups.

There are thousands of newsgroups, each addressing a single topic or area of interest. The MATLAB Central Newsreader posts and displays messages in the comp.soft-sys.matlab newsgroup.

**MATLAB Central**

You can use the integrated newsreader at the MATLAB Central website to read and post messages in this newsgroup. MATLAB Central is hosted by MathWorks.

Messages posted through the MATLAB Central Newsreader are seen by everyone using the newsgroups, regardless of how they access the newsgroups. There are several advantages to using MATLAB Central.

**One Account**

Your MATLAB Central account is tied to your MathWorks Account for easy access.

**Use the Email Address of Your Choice**

The MATLAB Central Newsreader allows you to define an alternative email address as your posting address, avoiding clutter in your primary mailbox and reducing spam.

**Spam Control**

Most newsgroup spam is filtered out by the MATLAB Central Newsreader.

**Tagging**

Messages can be tagged with a relevant label by any signed-in user. Tags can be used as keywords to find particular files of interest, or as a way to categorize your bookmarked postings. You may choose to allow others to view your tags, and you can view or search others’ tags as well as those of the community at large. Tagging provides a way to see both the big trends and the smaller, more obscure ideas and applications.

**Watch lists**

Setting up watch lists allows you to be notified of updates made to postings selected by author, thread, or any search variable. Your watch list notifications can be sent by email (daily digest or immediate), displayed in My Newsreader, or sent via RSS feed.

- Use a newsreader through your school, employer, or internet service provider
- Pay for newsgroup access from a commercial provider
- Use Google Groups
- Mathforum.org provides a newsreader with access to the comp.soft sys.matlab newsgroup
- Run your own server. For typical instructions, see: http://www.slyck.com/ng.php?page=2