Class SignalUtils


  • public class SignalUtils
    extends java.lang.Object
    Since:
    : 26.02.21
    Version:
    : 1.0
    Author:
    : Enrico Gamil Toros Project name : apt-decoder
    • Constructor Summary

      Constructors 
      Constructor Description
      SignalUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double correlation​(int[] x, int[] y)
      Function that returns correlation coefficient.
      static double[] crudeLowPass​(double[] signal, double frequency, double frequencyCut)
      Low Pass Filter.
      static void plotSignal​(double[] signal, int samplesToPlot)
      Plot a signal to a graph Is saved at project source root
      static void plotSignals​(double[] signal, double[] signal2, int samplesToPlot)
      Plots two signals (1 in blue, 2 in orange) Is saved at project source root
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SignalUtils

        public SignalUtils()
    • Method Detail

      • plotSignal

        public static void plotSignal​(@NotNull
                                      double[] signal,
                                      int samplesToPlot)
        Plot a signal to a graph Is saved at project source root
        Parameters:
        signal - Signal to plot, can't be null
        samplesToPlot - number of samples to plot
        Throws:
        java.lang.IllegalArgumentException - if samplesToPlot is > signal.length
      • plotSignals

        public static void plotSignals​(@NotNull
                                       double[] signal,
                                       @NotNull
                                       double[] signal2,
                                       int samplesToPlot)
        Plots two signals (1 in blue, 2 in orange) Is saved at project source root
        Parameters:
        signal - Signal 1
        signal2 - Signal 2
        samplesToPlot - number of samples to plot
        Throws:
        java.lang.IllegalArgumentException - if samplesToPlot is > signal.length
      • correlation

        public static double correlation​(@NotNull
                                         int[] x,
                                         @NotNull
                                         int[] y)
        Function that returns correlation coefficient.
        Parameters:
        x - array x, must have same length as y
        y - array y, must have same length as x
        Returns:
        value between -1 and 1 - 1 X and Y are negatively correlated + 1 X and Y are positively correlated
      • crudeLowPass

        public static double[] crudeLowPass​(double[] signal,
                                            double frequency,
                                            double frequencyCut)
        Low Pass Filter. Needs improvements
        Parameters:
        signal - Signal
        frequency - Frequency
        frequencyCut - Frequency to cut
        Returns:
        Low Pass Filtered Signal