function [y] = speedup(X,Y)

% Speed up the time series to match the sonic system

transposed=0;
S1=length(X);
t1=(1:S1)/S1;
L1=length(Y);
tL=(1:L1)./L1;
[row col]=size(Y);
if col==L1
    Y=Y';
    col=row;
    transposed=1;
end

for i=1:col
    j=find(~isnan(Y(:,col)));
    if ~isempty(j);
        if length(j)~=S1
            y(:,i)=interp1(tL(j),Y(j,i),t1,'linear','extrap');
        else
            y(:,i)=Y(:,i);
        end
    else
        y(:,i)=ones(length(S1),1)*NaN;
    end
end
if transposed
    y=y';
end