


TIDE_PRED predicts tidal currents for time t from TIDE_FIT output
TIDE_PRED(t,ell) predicts tidal currents for the time t
based on the ellipse output from TIDE_ELL.
[ucoef,unew]=tide_fit(jd,uv,periods,goplot)
ell=tide_ell(ucoef,periods)
[up,vp]=tide_pred(t,ell)
where
t = julian day vector to be predicted
up(:,n) = predicted u component for periods(n)
vp(:,n) = predicted v component for periods(n)

0001 function [up,vp]=tide_pred(t,ell) 0002 % TIDE_PRED predicts tidal currents for time t from TIDE_FIT output 0003 % TIDE_PRED(t,ell) predicts tidal currents for the time t 0004 % based on the ellipse output from TIDE_ELL. 0005 % 0006 % [ucoef,unew]=tide_fit(jd,uv,periods,goplot) 0007 % ell=tide_ell(ucoef,periods) 0008 % [up,vp]=tide_pred(t,ell) 0009 % 0010 % where 0011 % t = julian day vector to be predicted 0012 % up(:,n) = predicted u component for periods(n) 0013 % vp(:,n) = predicted v component for periods(n) 0014 0015 % Neglects mean in prediction. Uses same time origin as TIDE_FIT. 0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0017 % 5/20/98: 0018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0019 0020 periods=ell(:,1); 0021 freq=(2.*pi)*ones(size(periods))./periods; % cph 0022 nfreq=length(freq); 0023 0024 t=t(:); 0025 tt=t*24; % convert to hours from origin 0026 nt=length(tt); 0027 0028 umaj=ell(:,2); 0029 umin=ell(:,3); 0030 deg2rad=pi./180; 0031 inc=deg2rad.*ell(:,4); 0032 phase=deg2rad.*ell(:,5); 0033 0034 up=zeros(nt,nfreq);vp=up; 0035 ur=zeros(nt,1);vr=ur; 0036 0037 for nf=1:nfreq 0038 ur=umaj(nf).*cos(freq(nf).*tt - phase(nf)); 0039 vr=umin(nf).*sin(freq(nf).*tt - phase(nf)); 0040 up(:,nf)=cos(inc(nf)).*ur - sin(inc(nf)).*vr; 0041 vp(:,nf)=sin(inc(nf)).*ur + cos(inc(nf)).*vr; 0042 end 0043 0044 % compute and plot sum as check 0045 upsum=(sum(up'))'; 0046 vpsum=(sum(vp'))'; 0047 0048 plot(t,upsum,t,vpsum,'r') 0049 pause