Curve Fitting Toolbox for Surface Extrapolation

조회 수: 14 (최근 30일)
MATLAB_Soldier
MATLAB_Soldier 2022년 9월 19일
편집: Torsten 2022년 9월 19일
Hi everyone,
I am working with a fairly simple X,Y, Z dataset to extrapolate some datapoints outside of the data region. I have used the Curve Fitting toolbox to fit a surface to the datapoints which seems pretty good. I have used the toolbox to generate the code which can be found below. It shows me a nice figure which I am happy with. Unfortunately, I don't know how to use this surface.
My aim is to feed in xq, and xy values and it would tell me zq. How can I achieve this?
Many thanks.
% Data for 'Lowess' fit:
% X Input : BH_X
% Y Input : BH_Y
% Z Output: BH_Z
%% Fit: 'Lowess'.
[xData, yData, zData] = prepareSurfaceData( BH_X, BH_Y, BH_Z );
% Set up fittype and options.
ft = fittype( 'loess' );
opts = fitoptions( 'Method', 'LowessFit' );
opts.Normalize = 'on';
opts.Robust = 'Bisquare';
opts.Span = 0.2;
% Fit model to data.
[fitresult{2}, gof(2)] = fit( [xData, yData], zData, ft, opts );
% Create a figure for the plots.
figure( 'Name', 'Lowess' );
% Plot fit with data.
subplot( 2, 1, 1 );
h = plot( fitresult{2}, [xData, yData], zData );
legend( h, 'Lowess', 'BH_Z vs. BH_X, BH_Y', 'Location', 'NorthEast', 'Interpreter', 'none' );
% Label axes
xlabel( 'BH_X', 'Interpreter', 'none' );
ylabel( 'BH_Y', 'Interpreter', 'none' );
zlabel( 'BH_Z', 'Interpreter', 'none' );
grid on
view( -1.3, 14.3 );
% Plot residuals.
subplot( 2, 1, 2 );
h = plot( fitresult{2}, [xData, yData], zData, 'Style', 'Residual' );
legend( h, 'Lowess - residuals', 'Location', 'NorthEast', 'Interpreter', 'none' );
% Label axes
xlabel( 'BH_X', 'Interpreter', 'none' );
ylabel( 'BH_Y', 'Interpreter', 'none' );
zlabel( 'BH_Z', 'Interpreter', 'none' );
grid on
view( -1.3, 14.3 );

채택된 답변

Torsten
Torsten 2022년 9월 19일
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
xq = (xData(1)+xData(2))/2;
yq = (yData(1)+yData(2))/2;
zq = feval(fitresult,[xq yq])
  댓글 수: 2
MATLAB_Soldier
MATLAB_Soldier 2022년 9월 19일
Thank you. This is what I needed.
However, what are these two lines for?
xq = (xData(1)+xData(2))/2;
yq = (yData(1)+yData(2))/2;
Torsten
Torsten 2022년 9월 19일
편집: Torsten 2022년 9월 19일
Just test values for interpolation in [xq yq].

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

추가 답변 (1개)

William Rose
William Rose 2022년 9월 19일

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by