Home > m > helper > ltpda_matchvectors.m

ltpda_matchvectors

PURPOSE ^

LTPDA_RESAMPLE make the two vectors have the same length and sample rate

SYNOPSIS ^

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

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.
 
 usage: [xo, yo, fs] = mresample(x, y, xfs, yfs)
 
 M Hewitson 26-01-07
 
 $Id: ltpda_matchvectors.html,v 1.1 2007/06/08 14:15:10 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [xo, yo, fs] = ltpda_matchvectors(x, y, xfs, yfs)
0002 
0003 % LTPDA_RESAMPLE make the two vectors have the same length and sample rate
0004 % by down-sampling the one with the higher samplerate. Vectors are also
0005 % truncated to the length of the shorter vector.
0006 %
0007 % usage: [xo, yo, fs] = mresample(x, y, xfs, yfs)
0008 %
0009 % M Hewitson 26-01-07
0010 %
0011 % $Id: ltpda_matchvectors.html,v 1.1 2007/06/08 14:15:10 hewitson Exp $
0012 %
0013 
0014 % check the sample rates
0015 if yfs > xfs
0016   dv_disp('!!! vectors are not equal sample rates. Down-sampling y. !!!');
0017   y = resample(y, xfs, yfs);
0018   fs = xfs;
0019 end
0020 
0021 if xfs > yfs
0022   dv_disp('!!! vectors are not equal sample rates. Down-sampling x. !!!');
0023   x = resample(x,yfs,xfs);
0024   fs = yfs;
0025 end
0026 
0027 if xfs == yfs
0028   fs = xfs;
0029 end
0030 
0031 % now check the vector lengths
0032 nx = length(x);
0033 ny = length(y);
0034 
0035 if nx > ny
0036   dv_disp('!!! vectors are not equal lengths. Truncating x. !!!');
0037   x = x(1:ny);
0038 end
0039 if ny > nx
0040   dv_disp('!!! vectors are not equal lengths. Truncating y. !!!');
0041   y = y(1:nx);
0042 end
0043

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003