function [ out1,out2,out3 ]=dynmeshk(cptype,fs,tol)
% [ out1 ]=dynmeshk(cptype,fs) return the data series
% [ out1,out2,out3 ]=dynmeshk(cptype,fs,tol) return the fourier series
% Calculate the static transmission error
%cptype:type of coupling pairs: spdi rpdi spci rpci
% 1 2 3 4
%fs:sampling frequency
%format options
if nargout==1, fopt=0;else fopt=1;end
if nargin==2, tol=5;elseif nargin==3,fopt=1;end
global mnd betad alphatd Bspd Brpd zsd zpd zrd ksspd ksrpd
global mnc betac alphatc Bspc Brpc zsc zpc zrc ksspc ksrpc
global omegamd omegamc
switch cptype
case 1 %spdi
beta=betad; alphat=alphatd; mn=mnd; z1=zsd; z2=zpd; B=Bspd;k0=ksspd;
case 2 %rpdi
beta=betad; alphat=alphatd; mn=mnd; z1=zrd; z2=zpd; B=Brpd;k0=ksrpd;
case 3 %spci
beta=betac; alphat=alphatc; mn=mnc; z1=zsc; z2=zpc; B=Bspc;k0=ksspc;
case 4 %rpci
beta=betac; alphat=alphatc; mn=mnc; z1=zrc; z2=zpc; B=Brpc;k0=ksrpc;
end
d1=z1*mn/cos(beta);d2=z2*mn/cos(beta);
db1=d1*cos(alphat);db2=d2*cos(alphat);
da1=d1+2*mn;da2=d2+2*mn;
alphaat1=acos(db1/da1);alphaat2=acos(db2/da2);
epalpha=(z1*(tan(alphaat1)-tan(alphat))+z2*(tan(alphaat2)-tan(alphat)))/(2*pi);
epbeta=B*sin(beta)/(pi*mn);
epgamma=epalpha+epbeta;
betab=atan(tan(beta)*cos(alphat));
pmm=ceil(epgamma);
B0tao=@(tau) tau/epbeta.*(tau<epbeta & tau>0)+1.*(tau>=epbeta & tau<epalpha)+...
((epalpha+epbeta)-tau)/epbeta.*(tau>=epalpha & tau<epalpha+epbeta)+...
0.*(tau>=epalpha+epbeta | tau<=0);
taud=1/fs;
tau=0:taud:3*pmm;
k_tau=zeros(length(tau),1);
for ij=1:length(tau)
Bpt=0;
for ii=0:pmm-1+floor(tau(ij))
Bpt=Bpt+B0tao(tau(ij)-ii);
end
k_tau(ij)=Bpt*k0*B/cos(betab);
end
if fopt == 0
out1=k_tau(1+pmm/taud:1+2*pmm/taud);
else
switch cptype
case 1
Tm=2*pi/omegamd;
case 2
Tm=2*pi/omegamd;
case 3
Tm=2*pi/omegamc;
case 4
Tm=2*pi/omegamc;
end
tau=0:1/fs:1;
tt=Tm*tau.';
[out1,out2,out3]=dfseries(tt,k_tau(1:length(tt)),tol);
end
end
评论14