VMT_MeanXSLine

PURPOSE ^

Fits multiple transects at a single location with a single line. Inputs

SYNOPSIS ^

function [m,b] = VMT_MeanXSLine(z,A)

DESCRIPTION ^

 Fits multiple transects at a single location with a single line. Inputs
 are number of files (z) and data matrix (Z)(see ReadFiles.m). Outputs are
 the intercept (b) and slope (b) of the best fit line.

 (adapted from code by J. Czuba)

 P.R. Jackson, USGS, 12-9-08

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [m,b] = VMT_MeanXSLine(z,A)
0002 % Fits multiple transects at a single location with a single line. Inputs
0003 % are number of files (z) and data matrix (Z)(see ReadFiles.m). Outputs are
0004 % the intercept (b) and slope (b) of the best fit line.
0005 %
0006 % (adapted from code by J. Czuba)
0007 %
0008 % P.R. Jackson, USGS, 12-9-08
0009 
0010 
0011 
0012 %% Determine the best fit mean cross-section line from multiple transects
0013 % initialize vectors for concatenation
0014 
0015 x = [];
0016 y = [];
0017 
0018 for zi = 1 : z
0019        
0020     % concatenate long and lat into a single column vector for regression
0021     x=cat(1,x,A(zi).Comp.xUTM);
0022     y=cat(1,y,A(zi).Comp.yUTM);
0023     
0024     plot(A(zi).Comp.xUTM,A(zi).Comp.yUTM,'r')
0025     plot(A(zi).Comp.xUTMraw,A(zi).Comp.yUTMraw,'b')
0026         
0027 end
0028 
0029 % find the equation of the best fit line
0030 whichstats = {'tstat','yhat'};
0031 stats = regstats(y,x,'linear', whichstats);
0032 
0033 % mean cross-section line slope and intercept
0034 V.m = stats.tstat.beta(2);
0035 V.b = stats.tstat.beta(1);
0036 
0037 clear x y stats whichstats zi

Generated on Thu 21-Aug-2014 10:40:31 by m2html © 2005