-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateFit.m
38 lines (30 loc) · 844 Bytes
/
createFit.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function [fitresult, gof] = createFit(x, y, z)
%CREATEFIT(X,Y,Z)
% Create a fit.
%
% Data for 'untitled fit 1' fit:
% X Input : x
% Y Input : y
% Z Output: z
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% ÁíÇë²ÎÔÄ FIT, CFIT, SFIT.
% ÓÉ MATLAB ÓÚ 24-Jul-2020 17:28:19 ×Ô¶¯Éú³É
%% Fit: 'untitled fit 1'.
[xData, yData, zData] = prepareSurfaceData( x, y, z );
% Set up fittype and options.
ft = 'linearinterp';
% Fit model to data.
[fitresult, gof] = fit( [xData, yData], zData, ft, 'Normalize', 'on' );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, [xData, yData], zData );
legend( h, 'untitled fit 1', 'z vs. x, y', 'Location', 'NorthEast' );
% Label axes
xlabel x
ylabel y
zlabel z
grid on
view( -145.3, 11.4 );