Curve Fitting Toolbox for Surface Extrapolation

14 visualizaciones (últimos 30 días)
MATLAB_Soldier
MATLAB_Soldier el 19 de Sept. de 2022
Editada: Torsten el 19 de Sept. de 2022
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 );

Respuesta aceptada

Torsten
Torsten el 19 de Sept. de 2022
[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 comentarios
MATLAB_Soldier
MATLAB_Soldier el 19 de Sept. de 2022
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 el 19 de Sept. de 2022
Editada: Torsten el 19 de Sept. de 2022
Just test values for interpolation in [xq yq].

Iniciar sesión para comentar.

Más respuestas (1)

William Rose
William Rose el 19 de Sept. de 2022

Categorías

Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by