%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                      Digital to analog converter                        %
%            this function is designed for fish track only                %
%use sinc function to covert discrete signals to continuous signals.the   %      
%sampling interval of continuous signal is 1/5 of that of discrete       %
%signal.                                                                  %
%             x(t)=(sum over m)(x[m]*g(t-m*T))                            %
%             g(t)=sinc(t/T)                                              %
%where, T is the sampling interval of discrete signal                     %
%input: xd:discrete x                                                     %
%       yd:discrete y                                                     %
%output:xc:continuous x                                                   %
%       yc:continuous y                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [xc,yc] = d2a(xd,yd)
T=xd(2)-xd(1); %T:sampling interval of discrete signal
L=length(xd);
interval=T/5; %interval:the sampling interval of continous signal
xc=xd(1):interval:xd(L);%continuous x
%construct g
for m=1:L
   g(m,:)=sinc((xc-m*T)/T);
   z(m,:)=yd(m)*g(m,:);
end
yc=sum(z);%continuous y
end