function [fFac,uFac]=TPXOnodalfactors(dnum,Names) %f and u factors for the harmonics listed in cell array Names. %(e.g. Names={'MM' 'M2' S2'}; %Only those which are in the TPXO model are evaluated. %They are evaluated at time dnum (a Matlab datenumber). %See Table xxvi in A.T. Doodson (1928) 'On the Analysis of Tidal Observations' %Philosophical Transactions of the Royal Society of London. Series A, Vol. 227 %J. Luick, Thanksgiving Day, 2011, Adelaide N_TPXO=13; %if f and u are not reassigned below, they are probably solar %terms, i.e. have f=1 and u=0. f=ones(N_TPXO,1); u=zeros(N_TPXO,1); fFac=ones(length(Names),1); uFac=zeros(length(Names),1); t=(dnum+0.5-datenum(1900,1,1))/36525; VN=mod(360*(0.719954-5.372617*t+0.000006*t*t),360); VN(VN<0)=VN(VN<0)+360; VN=VN*pi/180; %coefficients cN=cos(VN); c2N=cos(2*VN); c3N=cos(3*VN); sN=sin(VN); s2N=sin(2*VN); s3N=sin(3*VN); % same list, in same order, as ALL_Constituents, ten per row, 112 in total TPXOnames={'MM' 'MF' 'Q1' 'O1' 'P1' 'K1' 'N2' 'M2' 'S2' 'K2' 'MN4' 'M4' 'MS4'}; %Set up variable names (e.g. hM2) and assign them each a value %(which is simply its position in the cell array). for n=1:length(TPXOnames) var=['h' TPXOnames{n}]; eval([var ' = n;']) end %Assign values for f and u of nonsolar constituents %Doodson Table XXVI (with u*pi/180) f(hMM)=1.0-0.1300*cN+0.0013*c2N; u(hMM)=0; f(hMF)=1.0429+0.4135*cN-0.004*c2N; u(hMF)=-0.4143*sN+0.0468*s2N-0.0066*s3N; f(hO1)=1.0089+.1871*cN-0.0147*c2N+0.0014*c3N; u(hO1)=0.1885*sN-0.0234*s2N+0.0033*s3N; f(hK1)=1.0060+0.1150*cN-0.0088*c2N+0.0006*c3N; u(hK1)=-0.1546*sN+0.0119*s2N-0.0012*s3N; f(hM2)=1.0004-0.0373*cN+0.0002*c2N; u(hM2)=-0.0374*sN; f(hK2)=1.0241+0.2863*cN+0.0083*c2N-0.0015*c3N; u(hK2)=-0.3096*sN+0.0119*s2N-0.0007*s3N; f(hQ1)=f(hO1); u(hQ1)=u(hO1); f(hN2)=f(hM2); u(hN2)=u(hM2); f(hMN4)=f(hM2)^2; u(hMN4)=2*u(hM2); f(hM4)=f(hM2)^2; u(hM4)=2*u(hM2); f(hMS4)=f(hM2); u(hMS4)=u(hM2); %Assign fFac and uFac for n=1:length(Names) var=['h' Names{n}]; eval(['fFac(n)= f(' var ');']) eval(['uFac(n)=u(' var ');']) end uFac=uFac*180/pi; uFac=mod(uFac,360);