Read me matlab code for plotting rcm snr vs distance

2
READ ME MATLAB Code for Plotting RCM SNR vs. Distance There are a lot of occasions where one needs to “see how far ranging works.” When such occasions arise, it is very easy to take a pair of P410s, set them up in the target environment, observe readings with RCM RET, and move the P410s apart until ranging stops reporting range values. The answer to the question is normally “the last big number you saw.” In principle, this is a pretty simple process. But the follow on questions are harder to answer. How far could it have gone? Were all of the readings credible? Where there any outliers? What was the Signal- to-Noise Ratio (SNR) of the signals? Did outliers have lower than expected SNR? Was performance limited by the lack of signal strength or an abundance of noise? What was the signal strength? What was the ambient noise level? How did these parameters vary with distance? Was the noise constant through the area or were there local hot spots? Did you measure the ranges in different environments? How did performance compare in different situations? The questions can be endless. Fortunately, RCM RET offers a way to capture and log data as tests are being conducted. This is easy. One opens the collected logfiles, extracts the data of interest, processes it, and plots the results. In practice it is more involved. It is necessary to build a parser, establish the data constructs, and then process the raw data into Signal, Noise, and SNR, and then plot. All of the data necessary to produce these values is available in the logfiles. While it isn’t particularly difficult to pick the right numbers, scale them properly, compute the results, and then validate your process, it is time consuming and prone to error. To avoid this drudgery, I have prepared sample MATLAB code (contained in this zip file) that is intended to simplify this process. This code will parse the data, compute Signal, Noise, and SNR, and then plot it. The parser is performed by the function readRcmLog. The computations are performed by Rcm_Full_SNR_Signal_Noise_vs_Range_LogfilePlotter Rcm_Short_SNR_Signal_Noise_vs_Range_LogfilePlotter The two logfile plotter routines are almost identical. The only difference is that since it is possible to log either short scans (350 length scans) or full scans (1632 length scans), I made two different routines to cover both types of logfile. I also provided a pair of sample logfiles to demonstrate the code. Here are some things to know about the code: 1. The parser is very stable and fixed. There is no need to ever modify this code. 2. The Plotting routines were made by hacking existing code. I am not the cleanest MATLAB coder, so forgive me. 3. When the code runs it will normally report errors. Most errors are trivial and can be ignored. The only ones worth attention are the ones that prevent you from plotting the results. While the code has worked well for all the data I took (and I took a lot), you might find a corner case that blows up the code. If you find such a case, please let me know. I won’t promise to fix it, but I will look at it and feel your pain. 4. Modify as you see fit. My objective is to help you get started. Here is an example plot produced by the code.

Transcript of Read me matlab code for plotting rcm snr vs distance

Page 1: Read me   matlab code for plotting rcm snr vs distance

READ ME – MATLAB Code for Plotting RCM SNR vs. Distance

There are a lot of occasions where one needs to “see how far ranging works.” When such occasions arise, it is very easy to take a pair of P410s, set them up in the target environment, observe readings with RCM RET, and move the P410s apart until ranging stops reporting range values. The answer to the question is normally “the last big number you saw.”

In principle, this is a pretty simple process. But the follow on questions are harder to answer. How far could it have gone? Were all of the readings credible? Where there any outliers? What was the Signal-to-Noise Ratio (SNR) of the signals? Did outliers have lower than expected SNR? Was performance limited by the lack of signal strength or an abundance of noise? What was the signal strength? What was the ambient noise level? How did these parameters vary with distance? Was the noise constant through the area or were there local hot spots? Did you measure the ranges in different environments? How did performance compare in different situations? The questions can be endless.

Fortunately, RCM RET offers a way to capture and log data as tests are being conducted. This is easy. One opens the collected logfiles, extracts the data of interest, processes it, and plots the results.

In practice it is more involved. It is necessary to build a parser, establish the data constructs, and then process the raw data into Signal, Noise, and SNR, and then plot. All of the data necessary to produce these values is available in the logfiles. While it isn’t particularly difficult to pick the right numbers, scale them properly, compute the results, and then validate your process, it is time consuming and prone to error.

To avoid this drudgery, I have prepared sample MATLAB code (contained in this zip file) that is intended to simplify this process.

This code will parse the data, compute Signal, Noise, and SNR, and then plot it. The parser is performed by the function readRcmLog. The computations are performed by

Rcm_Full_SNR_Signal_Noise_vs_Range_LogfilePlotter

Rcm_Short_SNR_Signal_Noise_vs_Range_LogfilePlotter

The two logfile plotter routines are almost identical. The only difference is that since it is possible to log either short scans (350 length scans) or full scans (1632 length scans), I made two different routines to cover both types of logfile. I also provided a pair of sample logfiles to demonstrate the code.

Here are some things to know about the code:

1. The parser is very stable and fixed. There is no need to ever modify this code. 2. The Plotting routines were made by hacking existing code. I am not the cleanest MATLAB coder,

so forgive me. 3. When the code runs it will normally report errors. Most errors are trivial and can be ignored. The

only ones worth attention are the ones that prevent you from plotting the results. While the code has worked well for all the data I took (and I took a lot), you might find a corner case that blows up the code. If you find such a case, please let me know. I won’t promise to fix it, but I will look at it and feel your pain.

4. Modify as you see fit. My objective is to help you get started.

Here is an example plot produced by the code.

Page 2: Read me   matlab code for plotting rcm snr vs distance

SNR (red) is computed by taking 10*Log10 of the ratio of the Signal and Noise and is presented in dB. Signal (green) is 10*Log10 the unscaled value of Vpeak (the strongest signal in the leading edge of the scan, typically a few nanoseconds after the leading edge). Noise is calculated by computing the standard deviation of most of the readings in the scan just prior to the leading edge. The plot of Noise (blue) is 10*log10 of noise/2000. 2000 is an arbitrary value chosen such that Noise would always be at the bottom of the plot.

While SNR is always important, plotting both Signal and Noise separately is valuable in that doing so will indicate whether changes in SNR are due to changes in signal or in noise (or both).

I find this tool endlessly useful and hope that it helps get you started, saves you time, and generally makes your life easier.

Alan Petroff

Principal Technologist, Time Domain