MATLAB: How to fit the data

curve fitting

I havent used curve fitting in matlab, Please someone do help me solve this out….
46 3.26 450 937 3050 0.51 37 32 135
35 3.48 450 438 1525 0.55 37 28 86
35 3.93 450 194 762 0.66 37 28 54.5
36 3.56 450 857 3050 2.23 37 28 232
35 3.77 450 405 1525 2.36 37 28 138
35 4.05 450 188 762 2.54 37 28 74
The above is few rows of my data. The columns 'A' to 'H' are the input variables and the column 'I' is the output. Using this data, I need to find out an equation that fits the given input and output, using curve fitting in matlab. It has to be done as a recursive procedure and is to be terminated when the 'residual' ie, the difference between the available result and the one found using the equation obtained from curve fitting is a minimum.
i used curve fitting as follows if not this way… please do reply what are the other possible way of doing it…

Best Answer

  • It depends on the model that you want to fit to your data. To do a linear regression, assuming some constant vector B multiplied by the first 8 columns of your data equals the 9th column, this would be appropriate:
    AI = [46 3.26 450 937 3050 0.51 37 32 135
    35 3.48 450 438 1525 0.55 37 28 86
    35 3.93 450 194 762 0.66 37 28 54.5
    36 3.56 450 857 3050 2.23 37 28 232
    35 3.77 450 405 1525 2.36 37 28 138
    35 4.05 450 188 762 2.54 37 28 74];
    AH = AI(:,1:8);
    I = AI(:,9);
    B = AH\I % Assume linear regression with AH*B = I
    producing:
    B =
    2.1354e+000
    -33.3235e+000
    37.5429e-003
    -1.4341e+000
    481.3711e-003
    7.9226e+000
    0.0000e+000
    0.0000e+000