1

I have captured RF data and am using dsp.SpectrumAnalyzer to find the frequency peaks of the signal. But the peaks are not reproducible. They are changed whenever I run the code again. My data is the same, so I should get the same results each time.

Someone suggested me to look at the random number that is used in MATLAB internal clock. But I have not found anything related yet.

Here is my code. I want stable and reproducible peak values.

Edit: here is the data file link. https://uofnelincoln-my.sharepoint.com/:u:/g/personal/mbaig4_unl_edu/EbQl4lG1PcpMr4bt8-Xqwf4BTMjKyMoC-PXKeMK1VwqCKg?e=yS9LZf

The Figure shows the spectrum of one of the frames. It get the spectrum but the peak values are changed a bit every time i run the code. I'm expecting to get the same peaks because data is the same. enter image description here

r_data=load("LTE5M_1s_t0.mat");
data=r_data.ans.Data;
measurements=[];    %scope measurements
peakValues=[];      %peak frequency and their RSSI
nframes=size(data,3);   %extract number of frames from the data

%% Initialize Spectrum analyzer with defined parameters
specScope = dsp.SpectrumAnalyzer('SpectrumType','Power density', ...
    'SampleRate',10000000, ...
    'FrequencySpan','Span and center frequency', ...
    'Span',10000000, ...
    'FrequencyResolutionMethod','WindowLength', ...
    'WindowLength',65536, ...
    'FFTLengthSource','Property', ...
    'FFTLength',65536, ...
    'Window','Hamming');

%% Peak Finder 
specScope.PeakFinder.NumPeaks = 10;
specScope.PeakFinder.Enable = true;
mdata=getMeasurementsData(specScope);
for counter = 1:nframes
                %Launch the spectrum analyzer
                specScope(data(:,:,counter));
                     if specScope.isNewDataReady
                        measurements = [measurements;getMeasurementsData(specScope)];
                        
                     end

end

peakValues=measurements.PeakFinder;
save("peaks.mat","peakValues",'-mat')
Baig
  • 11
  • 3
  • It doesn't look like your code uses anything to do with random numbers, so that sounds like a red herring. However, without a [mcve] it's impossible for us to reproduce your issue, we do not have `test.mat` so cannot run your code. Just observationally and with minimal context, that sample rate seems very high, are you actually getting all the samples through which you expect? – Wolfie Jul 26 '22 at 14:46
  • Could you elaborate on what is different on the results between runs? Are the results you are seeing close to what you are expecting or are they wildly different? My first guess would be that your scope configuration parameters are incorrect and so you are not reading the data correctly. But hard to tell without knowing more. – Jim Quirk Jul 26 '22 at 14:47
  • Another point is what does the spectrum look like once you get it into MATLAB? I am not familiar with the SpectrumAnalyzer packages but I am guessing that your code will find 10 "peaks" in the data regardless of whether or not there are actually any there (garbage in/garbage out). – Jim Quirk Jul 26 '22 at 14:51
  • @Wolfie. Thanks for your response. I have added data file link. I'm expecting same peak values each time i run the code. But They are not the same. – Baig Jul 26 '22 at 15:17
  • @JimQuirk. Thanks for reply. I added my data file link. The peaks are similar but not exactly the same. My data is standard LTE waveform which I captured using PlutoSDR. My data is same each time so I'm expecting to get the same frequency peak values whenever I run the code. right or wrong is not the concern at this time. but they should be same. But It changes a bit each time. Not wildly different but not exactly the same. – Baig Jul 26 '22 at 15:23
  • @Baig. I don't have the necessary toolboxes to execute the code, but if I just load the data and plot, it looks pretty much like noise. If the data is not looking as you would expect, then the low signal-to-noise could be causing the peak detection to fail (and even if it wasn't the results are meaningless). Is the peak detection algorithm deterministic? If not, then that could also cause variations. – Jim Quirk Jul 26 '22 at 16:40
  • @JimQuirk Thank you very much for looking into my data. Actually the data is time series data of LTE waveform for 10 MHz bandwidth and 10 MSPS sampling rate So plotting it in time domain won't make sense. I have uploaded the spectrum of one of the frames of this data. This image gives the exact visuals of LTE waveform. The only problem is, peaks of this graph keeps changing a bit whenever i run the code. My understanding is that i should get exactly the same peak values whenever i rerun it because the time domain data is the same and we performing some mathematical transformation on it. – Baig Jul 26 '22 at 21:13
  • @Baig Yes, I had looked at the data in the frequency domain also and finding a unique peak in that noisy signal is a somewhat arbitrary exercise. You may need to filter the data and/or play with the PeakFinderConfiguration settings to get meaningful results, but as I mentioned I haven't used this toolbox myself. Could you provide an example of the peaks values you receiving? – Jim Quirk Jul 27 '22 at 15:07
  • @Baig I'll admit that something odd is happening. I was able to install the dsp toolbox and I ran your code. I initially saw what I assume are the same variations that you were. To test further, I started playing with clearing the entire workspace before running. After I did this, the results were reproducible thereafter even if I didn't clear the workspace between runs. I don't understand why that is but it might be worth a try. – Jim Quirk Jul 27 '22 at 16:32

0 Answers0