producing an equation to fit on a plotted data

1 Ansicht (letzte 30 Tage)
milad babaei
milad babaei am 7 Jul. 2011
hi all, according to this code and data is there anyway to get an polynomial with low degree( for example 2nd order)or a surface equation to fit our data??please help me what should i do to fit an equation on my data.
code:
data =[0,1,1;0,2,1.02;0,3,1.11;0,4,1.21;0,5,1.30;0,6,1.4;0,7,1.59;0,8,1.78; 10,1,1;10,2,1.11;10,3,1.35;10,4,1.62;10,5,1.95;10,6,2.33;10,7,3.34;10,8,4.77; 20,1,1.01;20,2,1.39;20,3,2.12;20,4,3.29;20,5,5.17;20,6,8.29;20,7,22;20,8,61; 30,1,1.13;30,2,2.5;30,3,6.36;30,4,17.5;30,5,50;30,6,150;30,7,1400;30,8,14800];
mn = arrayfun(@(i1)length(unique(data(:,i1))),2:-1:1); c = mat2cell(reshape(data,mn(1),mn(2),[]),mn(1),mn(2),[1 1 1]); surf(c{:})

Antworten (3)

bym
bym am 8 Jul. 2011
create a design matrix of your x & y values like this:
d = [ones(length(data),1),data(:,1),data(:,2),...
data(:,1).^2,data(:,1).*data(:,2),data(:,2).^2];
this represents [ constant, x, y, x^2, x*y, y^2]. Then, to find the coefficients do:
c = d\data(:,3)
  3 Kommentare
milad babaei
milad babaei am 9 Jul. 2011
is there anyway to evaluate the values which are fitted by the equation???
milad babaei
milad babaei am 9 Jul. 2011
i run the code >>3.6228426607 is this the constant of equation???this fitted equation be cause of large range of data doesnt fit well..would u plz help me finding another type of equations to fit well?

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 9 Jul. 2011

Rick Rosson
Rick Rosson am 7 Jul. 2011
Please try:
sftool
or
cftool
HTH.

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by