------------------------------------------------------------------------------------------------------- contactpoint3.m This script is used for automatically locating the contact point. You need to supply z and d coordinates for the force curve, as well as tip parameters and a maximum indentation to use when fitting. Required arguments: z: a vector of z values (piezo height) for the force curve. Should be in meters. d: a vector of deflection values, should also be in meters and have the same number of points as z. tip: a 3-element struct containing tip parameters: tip.k: spring constant in N/m tip.type: either 'cone' or 'bead' tip.geom: cone angle or tip radius, depending on tip type. maxind: maximum amount of indentation data to use when fitting, in nm. The output will be the index value where the contact point occurs. ------------------------------------------------------------------------------------------------------- afmcntp.m This script does the actual fitting to give you the E value. Required arguments: z: a vector of z values (piezo height) for the force curve. Should be in meters. d: a vector of deflection values, should also be in meters and have the same number of points as z. tip: a 3-element struct containing tip parameters: tip.k: spring constant in N/m tip.type: either 'cone' or 'bead' tip.geom: cone angle or tip radius, depending on tip type. maxind: maximum amount of indentation data to use when fitting, in nm. plot: either 1 or 0 depending on whether you want it to show a plot. The output will be the elastic modulus in Pa, the contact point(index value) and the normalized fitting error. ------------------------------------------------------------------------------------------------------- Example usage: %import z and d from force curve data tip.k = 0.06; tip.type = 'cone'; tip.geom = 35; maxind = 500; index = contactpoint3(z,d,tip,maxind); %index will be the location of the contact point %now do the fit to get E value [E ctp err]=afmcntp(z_app,d_app,tip,[index maxind1],1); ------------------------------------------------------------------------------------------------------- It is possible to construct a simple loop to process many force curves. Example tip.k = 0.06; tip.type = 'cone'; tip.geom = 35; maxind = 500; %if you start with all of your z and d data in a struct for i = 1:20 z = fc(i).z; d = fc(i).d; index = contactpoint3(z,d,tip,maxind); %index will be the location of the contact point %now do the fit to get E value [E(i) ctp(i) err(i)]=afmcntp(z_app,d_app,tip,[index maxind1],1); end