MATLAB Answers

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 件のコメント
MJ
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:

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by