Time of Flight measurement

15 views (last 30 days)
Taher Sahara
Taher Sahara on 29 Apr 2020
I have a time domain signal and i want to calculate the time of flight for in general any such signals.
For that my code should detect the point of maxima(along with its time of occurence) of the first wave packet as marked in the image and the second point of maxima (along with its time of occurence). So after knowing the time of occurence of both peaks, time of flight can be calculated easily by calculating their difference.
This is easily done manually but how it can be done with the help of code?
Please help.

Answers (2)

darova
darova on 29 Apr 2020
Try this trick
p = [0.0772 0.7149
0.1256 0.7588
0.1878 0.8231
0.2431 0.7646
0.2869 0.3114
0.3836 0.3202
0.4597 0.3173
0.5541 0.3348
0.6187 0.3260
0.6855 0.3231
0.7339 0.4284
0.7800 0.3845
0.7984 0.4839
0.8353 0.3874
0.8813 0.3845
0.9320 0.3465
0.9850 0.3377];
x = p(:,1);
y = p(:,2);
plot(x,y)
[~,ix1] = max(y); % calculate max
[~,ix2] = max(y(10:end)); % calculate max in second half of the data
ix2 = 9+ix2;
line(x(ix1),y(ix1),'marker','*')
line(x(ix2),y(ix2),'marker','*')
  1 Comment
Taher Sahara
Taher Sahara on 30 Apr 2020
This wont work everytime as the wave packet's time may vary so everytime i have to set the range for second maximum. I want to make a generalized code which will work for all signals. The code itself must consider the range after first wave packet diminishes.

Sign in to comment.


Bjorn Gustavsson
Bjorn Gustavsson on 29 Apr 2020
You might get somewhere by calculating the spectrogram (short-time FT) of your signal. That might allow you to identify the time for peaks of the spectral power (possibly above some cut-off-frequency?). Have a look at spectrogram.
HTH
  7 Comments
Taher Sahara
Taher Sahara on 4 May 2020
Edited: Taher Sahara on 4 May 2020
Thanks for the reply, ill try conv function to create an envelope and then extract the required data.
Max function works fine when i know the range, in my case the time of arrival of wave packets may vary so every time a given range may not work. That is why im looking for an alternative.
Bjorn Gustavsson
Bjorn Gustavsson on 4 May 2020
But you only need to exclude the first pulse, right? The rest is signal of your interest, right? If that's the case you only need to exclude the first pulse and then the rest is where you should look for maxima. You could also simply look for local maxima, i.e. points where S(idx)-S(idx-1)>0 and S(idx+1)-S(idx)<0. You can get every such local maxima rather efficiently with diff. There might also be a file-exchange submission doing this.

Sign in to comment.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!