Home > m > helper > ltpda_matchvectors.m

ltpda_matchvectors

PURPOSE ^

LTPDA_RESAMPLE make the two vectors have the same length.

SYNOPSIS ^

function [x, y, fs] = ltpda_matchvectors(x, y, xfs, yfs)

DESCRIPTION ^

 LTPDA_RESAMPLE make the two vectors have the same length.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: LTPDA_RESAMPLE make the two vectors have the same length and
              sample rate by down-sampling the one with the higher samplerate.
              Vectors are also truncated to the length of the shorter vector.

 CALL:       [xo, yo, fs] = mresample(x, y, xfs, yfs)

 INPUTS:     x   - data vector
             y   - data vector
             xfs - sample rate of x
             yfs - sample rate of y

 OUTPUTS:    x  - new data vector
             y  - new data vector
             fs - new sample rate of x AND y

 VERSION: $Id: ltpda_matchvectors.m,v 1.3 2007/08/14 09:25:24 ingo Exp $

 HISTORY: 26-01-2007 M Hewitson
             Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x, y, fs] = ltpda_matchvectors(x, y, xfs, yfs)
0002 % LTPDA_RESAMPLE make the two vectors have the same length.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: LTPDA_RESAMPLE make the two vectors have the same length and
0007 %              sample rate by down-sampling the one with the higher samplerate.
0008 %              Vectors are also truncated to the length of the shorter vector.
0009 %
0010 % CALL:       [xo, yo, fs] = mresample(x, y, xfs, yfs)
0011 %
0012 % INPUTS:     x   - data vector
0013 %             y   - data vector
0014 %             xfs - sample rate of x
0015 %             yfs - sample rate of y
0016 %
0017 % OUTPUTS:    x  - new data vector
0018 %             y  - new data vector
0019 %             fs - new sample rate of x AND y
0020 %
0021 % VERSION: $Id: ltpda_matchvectors.m,v 1.3 2007/08/14 09:25:24 ingo Exp $
0022 %
0023 % HISTORY: 26-01-2007 M Hewitson
0024 %             Creation
0025 %
0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0027 
0028 % check the sample rates
0029 if yfs > xfs
0030   dv_disp('!!! vectors are not equal sample rates. Down-sampling y. !!!');
0031   y = resample(y, xfs, yfs);
0032   fs = xfs;
0033 end
0034 
0035 if xfs > yfs
0036   dv_disp('!!! vectors are not equal sample rates. Down-sampling x. !!!');
0037   x = resample(x,yfs,xfs);
0038   fs = yfs;
0039 end
0040 
0041 if xfs == yfs
0042   fs = xfs;
0043 end
0044 
0045 % now check the vector lengths
0046 nx = length(x);
0047 ny = length(y);
0048 
0049 if nx > ny
0050   dv_disp('!!! vectors are not equal lengths. Truncating x. !!!');
0051   x = x(1:ny);
0052 end
0053 if ny > nx
0054   dv_disp('!!! vectors are not equal lengths. Truncating y. !!!');
0055   y = y(1:nx);
0056 end
0057

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003