필터 지우기
필터 지우기

How do I replicate curve fit figure with an equation?

조회 수: 1 (최근 30일)
MJ
MJ 2021년 5월 6일
편집: MJ 2021년 5월 6일
I would like to replicate the following plane, which was plotted with the curve fitting toolbox.
The toolbox gave me this information for the plane:
% Linear model Poly22:
% ans(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2
% where x is normalized by mean 14.91 and std 0.5073
% and where y is normalized by mean -7.804 and std 23.72
% Coefficients (with 95% confidence bounds):
% p00 = -3.562 (-3.609, -3.516)
% p10 = -0.0439 (-0.1117, 0.02388)
% p01 = 22.79 (22.72, 22.85)
% p20 = 0.04982 (-0.08557, 0.1852)
% p11 = 0.06292 (-0.1923, 0.3182)
% p02 = 1.543 (1.41, 1.675)
But when I plot it with the code
p00 = -3.562 ; p10 = -0.0439 ; p01 = 22.79 ;
p20 = 0.04982 ; p11 = 0.06292 ; p02 = 1.543 ;
syms x y
z = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2;
fsurf(z, [13.5 16], 'edgecolor', 'none');
xlabel('x'); ylabel('y'); zlabel('z');
I do not get the proper coordinates and end up with this and I'm not sure how to fix it:
I think it has to do with the 'normalized by mean xx and std yy ' but I don't know how it works

답변 (1개)

KSSV
KSSV 2021년 5월 6일
You can use plot to plot the plane you want.
  댓글 수: 9
KSSV
KSSV 2021년 5월 6일
You can normalize by using:
x = (x - mean_val) /std_val;
MJ
MJ 2021년 5월 6일
편집: MJ 2021년 5월 6일
I'm still not getting a solution. This is my code and output:
p00 = -3.562 ; p10 = -0.0439 ; p01 = 22.79 ;
p20 = 0.04982 ; p11 = 0.06292 ; p02 = 1.543 ;
xp = (x - 14.91) /0.5073;
yp = (y + 7.804) /23.72;
xp = linspace(min(xp),max(xp)) ;
yp = linspace(min(yp),max(yp)) ;
[xp,yp] = meshgrid(xp,yp) ;
my_sf = p00 + p10.*xp + p01.*yp + p20.*xp.^2 + p11.*xp.*yp + p02.*yp.^2;
figure(2)
surf(xp,yp,my_sf)
title('using surf')
xlabel('x') ; ylabel('y') ; zlabel('z') ;
This is the graph I want:

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by