Curve Fitting Toolbox for Surface Extrapolation

14 次查看(过去 30 天)
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