forked from INSIGNEO/AFM_Youngs_modulus_fit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateFitHertz.m
38 lines (30 loc) · 1.07 KB
/
createFitHertz.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
37
38
function [fitresult, gof] = createFitHertz(height_pos, force_pos)
%CREATEFIT1(HEIGHT_POS,FORCE_POS)
% Create a fit.
%
% Data for 'untitled fit 1' fit:
% X Input : height_pos
% Y Output: force_pos
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 20-Nov-2015 18:06:53
%% Fit: 'untitled fit 1'.
[xData, yData] = prepareCurveData( height_pos, force_pos );
% Set up fittype and options.
ft = fittype( 'a*x^(3/2)', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = 0.000663163674281653;
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
% % % Plot fit with data.
% figure( 'Name', 'Hertz fit', 'Visible','off' );
% h = plot( fitresult, xData, yData );
% legend( h, 'Force [nN] vs. height [nm]', 'Hertz fit', 'Location', 'NorthEast' );
% % Label axes
% xlabel ('Height [nm]')
% ylabel ('Force [nN]')
% grid on