Curve Fitting Toolbox for Surface Extrapolation

12 ビュー (過去 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 件のコメント
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 日

Community Treasure Hunt

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

Start Hunting!

Translated by