Results 1 to 7 of 7

Math Help - MATHEMATICA FindFit experimental data

  1. #1
    Newbie
    Joined
    Feb 2010
    Posts
    6

    MATHEMATICA FindFit experimental data

    Hi everyone,
    I want use FindFit for Data witch i read from a file, but i can't do it, please help me to solve this problem.
    i do this:

    data = ReadList["base3.dat", {Number, Number}];
    voltage = data[[All, 1]];
    current = data[[All, 2]];
    FindFit[data,a*x + b*y + c*x*y + e*x^2 + e*y^2, {a, b, c, e, d}, {x, y}];

    FindFit::fitc: Number of coordinates (1) is not equal to the number of variables (2).


    help me if you can please
    Last edited by CaptainBlack; February 12th 2010 at 11:21 PM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member
    Joined
    Aug 2008
    Posts
    903
    That error means your list of data is not a list of {x,y,z} values like:

    mydata = {{1, 1, 1}, {2, 2, 3}, {3, 3, 3}, {4, 4, 3}};

    FindFit[mydata,
    a*x + b*y + c*x*y + e*x^2 + e*y^2, {a, b, c, e, d}, {x, y}]

    First make sure your data is in the correct format: Test the code first with an explicit definition of the data like I did above. Then get the file reading part to read in the data as the explicit format you now know works. If you want to fit {x,y} pairs in the form of a function y=f(x), then you'll have to specify the expression for the function and just one variable {x}. There are however other functions that may suit your need like Fit, Interpolating Function, etc. Check the help.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Feb 2010
    Posts
    6

    Exclamation

    thanks, but i have to use a function of 2 variables
    D(V,I )=a*I+b*V+c*I*V+d*I^2+e*V^2;
    for fiting data I=f(V), i don't have z
    mydata:
    V I
    0.047790 9.01875E-6
    0.070060 1.40463E-5
    0.082600 1.6855E-5
    0.089750 1.88125E-5
    0.108330 2.28212E-5
    0.119740 2.56288E-5
    0.132350 2.97075E-5
    0.153210 3.39375E-5
    0.157250 3.668E-5
    0.168920 3.91425E-5
    0.196460 4.713E-5
    0.206590 5.09363E-5
    0.230800 5.8345E-5
    0.236900 6.17413E-5
    0.244330 6.4705E-5
    0.251710 6.73688E-5
    0.278770 7.55775E-5
    0.295320 8.209E-5
    0.300400 8.308E-5
    0.319740 9.21838E-5
    0.322990 9.53775E-5
    0.353020 1.0984E-4
    0.360520 1.1125E-4
    0.367660 1.17813E-4
    0.388450 1.2791E-4
    0.401650 1.35332E-4
    0.418820 1.5154E-4
    0.424540 1.55591E-4
    0.438110 1.58598E-4
    0.463590 1.92103E-4
    0.477580 2.02443E-4
    0.483600 2.05795E-4
    0.489890 2.10896E-4
    0.520780 2.36406E-4
    0.529070 2.43365E-4
    what i do
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Super Member
    Joined
    Aug 2008
    Posts
    903
    Then is D(I,v) equal to some constant? For example, suppose I have the relationship:

    k=aI+bV+cIV+dI^2+eV^2

    and I want to find the parameters \{a,b,c,d,e\} so that when I solve that equation for I=f(V), the resulting function fits the data sets. Then I'd use Solve:

    Code:
    In[20]:=
    Solve[k == a*i + b*v + c*i*v + d*i^2 + 
        e*v^2, i]
    
    Out[20]=
    {{i -> (-a - c*v + Sqrt[(-a - c*v)^2 + 
            4*d*(k - b*v - e*v^2)])/(2*d)}, 
      {i -> -((a + c*v + Sqrt[(-a - c*v)^2 + 
             4*d*(k - b*v - e*v^2)])/(2*d))}}
    Obviously that's two equations. Suppose I just use one of them. Then I'd run:

    FindFit[myData, myIFunction,{a,b,c,d,e},v]
    Last edited by shawsend; February 13th 2010 at 07:00 AM. Reason: added parameters to FindFit
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Feb 2010
    Posts
    6

    Unhappy

    i want know where is the problem when i do :

    [PHP]
    xtab = ReadList["V_base1.dat", Number];
    ytab = ReadList["I_base1.dat", Number];
    FindFit[Transpose[{xtab, ytab}],
    a*y + b*x + c*x*y + d*y^2 + e*y^2, {a, b, c, d, e}, {x, y}]

    FindFit::fitc: "\!\(\*
    StyleBox[\"\\\"Number of coordinates (\\\"\", \"MT\"]\)\!\(\* StyleBox[\"1\", \"MT\"]\)\!\(\* StyleBox[\"\\\") is not equal to the number of variables (\\\"\", \"MT\"]\)\!\(\* StyleBox[\"2\", \"MT\"]\)\!\(\* StyleBox[\"\\\").\\\"\", \"MT\"]\) "
    [/PHP]


    i add an another coordinates, i do this
    [PHP]ztab = xtab*ytab;
    FindFit[Transpose[{xtab, ytab, ztab}],
    a*y + b*x + c*x*y + d*y^2 + e*y^2, {a, b, c, d, e}, {x, y}]
    {a -> 8.38184*10^-16, b -> -6.49935*10^-17, c -> 1.,
    d -> -5.5458*10^-16, e -> -1.95062*10^-16}[/PHP]

    but, the resultats are wrong,

    hhhh, sorry showsend, what i do now
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Super Member
    Joined
    Aug 2008
    Posts
    903
    You mean you do this:

    Code:
    ztab = xtab*ytab;
    myvals = FindFit[Transpose[{xtab, ytab, ztab}], 
      a*y + b*x + c*x*y + d*y^2 + e*y^2, {a, b, c, d, e}, {x, y}]
    {a -> 8.38184*10^-16, b -> -6.49935*10^-17, c -> 1., 
     d -> -5.5458*10^-16, e -> -1.95062*10^-16}
    myfun[x_, y_] := a*y + b*x + c*x*y + d*y^2 + e*y^2 /. myvals;
    Plot3D[myfun[x, y], {x, 1, 5}, {y, 1, 5}]
    and the plot does not look like what it should look like? If that is the case then I don't know what's wrong because the code looks ok to me.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Feb 2010
    Posts
    6

    Question

    but when i change ztab the coefficients a,b,c,d,e changes, can i use the definition of D(I,V)=integral of VdI from 0 to I;
    what can i do
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. findfit mathematica
    Posted in the Math Software Forum
    Replies: 1
    Last Post: December 13th 2009, 02:48 PM
  2. Mathematica FindFit - proper format question
    Posted in the Math Software Forum
    Replies: 8
    Last Post: September 27th 2009, 06:59 AM
  3. Help with surface plotting experimental data (Matlab)
    Posted in the Math Software Forum
    Replies: 1
    Last Post: August 3rd 2009, 05:02 AM
  4. stats - Experimental Data and Design Analysis
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: August 13th 2006, 12:55 PM
  5. Saxon algebra 2 (experimental data)
    Posted in the Advanced Algebra Forum
    Replies: 4
    Last Post: January 26th 2006, 10:39 AM

Search Tags


/mathhelpforum @mathhelpforum