How to use regression to find equation of data set?

20 views (last 30 days)
Dear All,
I would like to ask for some help.
I am trying to find the equation present my data.
But io stuck when use regression method.
could someone help me?
i assume my equation is:
z = a*x^n +b*y+c
Thanks so much!
Han
x = [12 12.5 13 13.5 14
]
x = 1×5
12.0000 12.5000 13.0000 13.5000 14.0000
y = [61 61.5 62 62.5 63
]
y = 1×5
61.0000 61.5000 62.0000 62.5000 63.0000
z = [120 114 103 93 80
124 120 109 97 85
128 121 113 101 88
130 125 116 105 92
134 128 119 109 96
]
z = 5×5
120 114 103 93 80 124 120 109 97 85 128 121 113 101 88 130 125 116 105 92 134 128 119 109 96
surf(x,y,z)

Accepted Answer

KSSV
KSSV on 3 Nov 2022
x = [12 12.5 13 13.5 14] ;
y = [61 61.5 62 62.5 63] ;
[X,Y] = meshgrid(x,y) ;
Z = [120 114 103 93 80
124 120 109 97 85
128 121 113 101 88
130 125 116 105 92
134 128 119 109 96] ;
x = X(:) ;
y = Y(:) ;
z = Z(:) ;
sf = fit([x, y],z,'poly22')
Linear model Poly22: sf(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 Coefficients (with 95% confidence bounds): p00 = -3160 (-6274, -46.38) p10 = 55.49 (9.233, 101.7) p01 = 90.67 (-8.557, 189.9) p20 = -4.514 (-5.311, -3.717) p11 = 0.68 (0.01303, 1.347) p02 = -0.7429 (-1.54, 0.05432)
plot(sf,[x y],z)
  5 Comments
KSSV
KSSV on 5 Nov 2022
x = [12 12.5 13 13.5 14] ;
y = [61 61.5 62 62.5 63] ;
[X,Y] = meshgrid(x,y) ;
Z = [120 114 103 93 80
124 120 109 97 85
128 121 113 101 88
130 125 116 105 92
134 128 119 109 96] ;
x = X(:) ;
y = Y(:) ;
z = Z(:) ;
sf = fit([x, y],z,'poly22')
Linear model Poly22: sf(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 Coefficients (with 95% confidence bounds): p00 = -3160 (-6274, -46.38) p10 = 55.49 (9.233, 101.7) p01 = 90.67 (-8.557, 189.9) p20 = -4.514 (-5.311, -3.717) p11 = 0.68 (0.01303, 1.347) p02 = -0.7429 (-1.54, 0.05432)
zi = sf(x,y) ;
figure
hold on
surf(X,Y,Z)
plot3(x,y,zi,'*b')
view(3)

Sign in to comment.

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!