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.
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')