Skip to main content
. 2021 Aug 17;21(16):5532. doi: 10.3390/s21165532
Algorithm 1 Frequency Domain Feature Matching Algorithm
Input: Training dataset: Dtrain={(Xtrain(i),Ytrain(i)),i=1,2,3,,k}; length of training dataset: k;
Test dataset: Dtest={(Xtest(i),Ytest(i)),i=1,2,3,,s}; length of test dataset: s;
Fast Fourier transform (FFT): (·);
The number of selected feature frequencies for each sample: FN=10;
The function that returns the index of the array sorted in ascending order: argsort(·);
The function that reverses the array and returns the first FN elements: ReverseFN(·);
The number of categories: m;
The number of selected feature frequencies for each category: n;
Scoring function with scoring rules 1, 2 and 3: SR{A,B}; A is feature frequencies; B is feature matrix.
Output: Feature matrix with size of m×n;
Scoreboard of all test samples.
Training stage: Obtain feature matrix with size of m×n
for i[1,k] do
      XtrainFFT(i)=(Xtrain(i))  (Obtain the frequency spectrums of k training samples by FFT);
      [f1i,f2i,,fFNi]=ReverseFN{argsort[XtrainFFT(i)]};
      Feature Frequencies(i)=[f1i,f2i,,fFNi]
      (Extract FN feature frequencies from frequency spectrum of each training sample);
end for
for label[1,m] do
      AFlabel=[  ];
      for i[1,k] do
          if Ytrain(i)==label then
          Append Feature Frequencies(i) to the end of the list AFlabel;
end if
end for
      Count the occurrence times of feature frequencies in AFlabel and sort them in descending order;
      The feature sequence Flabel consists of the first n feature frequencies;
      Flabel=[Flabel1,Flabel2,,Flabeln];
end for
Feature Matrix=[F11F12F21F22F1nF2nFm1Fm2Fmn];
return  Feature Matrix
Test stage: Calculate scoreboard of all test samples
Scoreboard=[  ];
for j[1,s] do
      XtestFFT(j)=(Xtest(j))  (Obtain the frequency spectrums of s test samples by FFT);
      [f1j,f2j,,fFNj]=ReverseFN{argsort[XtestFFT(j)]};
      Feature Frequencies(j)=[f1j,f2j,,fFNj]
      (Extract FN feature frequencies from frequency spectrum of each test sample);
      Scorej=0 (Initialize score);
      [Sj1,Sj2,,Sjm]= SR{Feature Frequencies(j), Feature Matrix};
      Scorej=[Sj1,Sj2,,Sjm];
      Append Scorej to the end of the list Scoreboard;
end for
Scoreboard=[S11S12S21S22S1mS2mSs1Ss2Ssm];
return  Scoreboard