DSPRelated.com
Forums

TDOA and localisation (inexperienced Matlab user)

Started by nickch August 4, 2007
On Aug 9, 3:37 pm, Jerry Avins <j...@ieee.org> wrote:
> mnentwig wrote: > > ... > > > You'll need to oversample, otherwise the accuracy is too bad, given the > > velocity of sound (one sample at 44.1ksps corresponds to 7 mm) > > Easily done inside the FFT by zero-padding - split FFT(sig1) in the middle > > and insert for example zeros with 3 x the length for oversampling of four. > > Do I understand correctly that you propose to add information by zero > padding? > > ... > > Jerry > ...
It looks like more samples are desired in the delay domain to resolve a peak position to a finer scale than uninterpolated peak-picking can provide. Zero-padding FFT interpolation does that. In Matlab, adding the zeros in the middle of the signal can correctly implement that. Why would anyone call that adding information? Dale B. Dalrymple http://dbdimages.com
>> It looks like more samples are desired in the delay domain
Exactly that: Zero padding in the frequency domain gives me oversampling in the time domain, so I can resolve the delay between the signals with higher resolution. Sorry if that was unclear, thanks for clarification. Cheers Markus
>The xcorr method to obtain TDoA is all good if the signals do not contain >too much noise. If the signals are corrupted by noise you better use one >of the Generalized Cross Correlation (GCC) methods like PHAT, SCOT, HT, >etc. > >Fortunately there is a pretty good, and easy to use, implementations of >GCC in the Matlab file exchange page: > > >http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8581&objectType=file > > >Here is a little example of how I used it. I am not expert so don't
expect
>much of this code. Replace xnoisy and ynoisy with your data obtained
from
>the sensors and set Nfft and Fs to your needs. You can read the help
files
>for pwelch and cpsd for details. For more information on GCC methods
simply
>google for "Generalized Cross Correlation". > > >%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% >% Estimate the spectra. >%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% >[Sxx, Fxx] = pwelch(xnoisy,[],[],Nfft, Fs); >[Syy, Fyy] = pwelch(ynoisy,[],[],Nfft, Fs); >[Sxy, Fxy] = cpsd(xnoisy,ynoisy,[],[], Nfft, Fs); > >%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% >% Obtain the Generalized Correlation >%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% >[corr1, t1] = GCC('unfiltered',Sxx, Syy, Sxy, Fs, length(xnoisy), Nfft); >[corr2, t2] = GCC('scot', Sxx, Syy, Sxy, Fs, length(xnoisy), Nfft); >[corr3, t3] = GCC('roth', Sxx, Syy, Sxy, Fs, length(xnoisy), Nfft); >[corr4, t4] = GCC('phat', Sxx, Syy, Sxy, Fs, length(xnoisy), Nfft); >[corr5, t5] = GCC('cps-m', Sxx, Syy, Sxy, Fs, length(xnoisy), Nfft); >[corr6, t6] = GCC('ht', Sxx, Syy, Sxy, Fs, length(xnoisy), Nfft); > >figure(1); >subplot(321); >plot(t1,corr1); >%axis([-1 1 -1 1]); >[m,k] = max(corr1); >k = t1(k); >title('Unfiltered GCC'); >text(1e-4,0.5,strcat(num2str(k),'sec')); > >subplot(322); >plot(t2,corr2); >%axis([-30e-6 30e-6 -1.5 1.5]); >[m,k] = max(corr2); >k = t2(k); >title('SCOT GCC'); >text(1e-4,0.5,strcat(num2str(k),'sec')); > >subplot(323); >plot(t3,corr3); >%axis([-1 1 -1 1]); >[m,k] = max(corr3); >k = t3(k); >title('ROTH GCC'); >text(1e-4,0.5,strcat(num2str(k),'sec')); > >subplot(324); >plot(t4,corr4); >%axis([-1 1 -1 1]); >[m,k] = max(corr4); >k = t4(k); >title('PHAT GCC'); >text(1e-4,0.5,strcat(num2str(k),'sec')); > >subplot(325); >plot(t5,corr5); >%axis([-1 1 -1 1]); >[m,k] = max(corr5); >k = t5(k); >title('cps-m GCC'); >text(1e-4,0.5,strcat(num2str(k),'sec')); > >subplot(326); >plot(t6,corr6); >%axis([-1 1 -1 1]); >[m,k] = max(corr6); >k = t6(k); >title('HT GCC'); >text(1e-4,0.5,strcat(num2str(k),'sec'));
I USED YOUR CODE BUT I AM HAVING A PROBLEM. MATLAB SAYS THAT THERE IS SOME KIND OF ERROR AND THIS IS WHAT IT SAYS: ??? Error using ==> unknown Matrix dimensions must agree. Error in ==> GCC at 166 R = Pxy .* W; Error in ==> TDOA at 16 [corr1, t1] = GCC('unfiltered',Sxx, Syy, Sxy, Fs, length(xnoisy), Nfft); DOES ANYBODY KNOW HOW TO SOLVE THE PROBLEM?