merge 'develop'
This commit is contained in:
commit
5e19f5550a
|
|
@ -1,4 +1,4 @@
|
|||
function power = frequencySpectrum(signal, fs, resolution)
|
||||
function power = frequencySpectrum(signal, fs, resolution,RoI)
|
||||
%%%%%%%%%%%%%%%%%%
|
||||
%function power = frequencySpectrum(signal, fs, pad)
|
||||
%
|
||||
|
|
@ -8,6 +8,7 @@ function power = frequencySpectrum(signal, fs, resolution)
|
|||
% - signal: the input signal to process
|
||||
% - fs: the sampling rate in Hz
|
||||
% - resolution: frequency resolution in Hz, signal will be padded with zeros if necessary
|
||||
% - RoI: region of interest
|
||||
%
|
||||
% Output:
|
||||
% - power: the power spectrum
|
||||
|
|
@ -52,12 +53,14 @@ subplot(1,3,2) % linear frequency plot
|
|||
f = (0:n-1)*(fs/n); % frequency range
|
||||
plot(f,power, 'b*'); hold on;
|
||||
plot(f,power, 'r');
|
||||
xlim(RoI);
|
||||
title("Frequency Linear ");
|
||||
xlabel('Frequency (Hz)')
|
||||
ylabel('Power (a.u.)')
|
||||
|
||||
subplot(1,3,3) % log frequency plot
|
||||
plot(f,10*log10(power/power(ind)));
|
||||
xlim(RoI);
|
||||
title("Frequency Log");
|
||||
xlabel('Frequency (Hz)')
|
||||
ylabel('Power (dB)')
|
||||
|
|
|
|||
23
main.m
23
main.m
|
|
@ -1,6 +1,6 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%
|
||||
% UNKNOWN SIGNAL
|
||||
% Sampling frequency: 300 Hz
|
||||
% Sampling frequency: 200 Hz
|
||||
% Duration; 2 s
|
||||
% First second: 0.1Hz, 30 Hz, 30.5 Hz, 60 Hz, 61 Hz
|
||||
% Second second: 0.1Hz, 32 Hz, 36 Hz, 64 Hz, 72 Hz
|
||||
|
|
@ -14,7 +14,7 @@ signal = csvread('unknownsignal.csv');
|
|||
|
||||
%%%%%SIGNAL CHARACTERISTICS%%%%%
|
||||
% sets sampling frequency
|
||||
fps = 300; % -> freqMax of the signal should be < 150 Hz (Shannon-Nyquisit theorem), in practice freqMax < 60 Hz would be better
|
||||
fps = 200; % -> freqMax of the signal should be < 150 Hz (Shannon-Nyquisit theorem), in practice freqMax < 60 Hz would be better
|
||||
|
||||
% computes the duration of the signal
|
||||
duration = length(signal) / fps; % in s
|
||||
|
|
@ -22,6 +22,9 @@ duration = length(signal) / fps; % in s
|
|||
% estimates its original frequency resolution
|
||||
resolution = fps / length(signal); % in Hz
|
||||
|
||||
%crop the Power spectrums over the region of interest
|
||||
RoI=[5,20];
|
||||
|
||||
%%%%%STATIONARITY%%%%%
|
||||
% temporal plot
|
||||
figure;
|
||||
|
|
@ -48,14 +51,14 @@ signal_2 = signal(end/2+1:end);
|
|||
%%%%%SPECTRAL ANALYSIS (RECTANGULAR WINDOW)%%%%%
|
||||
%plots power spectrum with rectangular window
|
||||
% 1st part of the signal with 1 Hz resolution
|
||||
frequencySpectrum(signal_1, fps, 1);
|
||||
frequencySpectrum(signal_1, fps, 1, RoI);
|
||||
% 1st part of the signal with 0.5 Hz resolution
|
||||
frequencySpectrum(signal_1, fps, 0.5);
|
||||
frequencySpectrum(signal_1, fps, 0.5, RoI);
|
||||
|
||||
% 2nd part of the signal with 1 Hz resolution
|
||||
frequencySpectrum(signal_2, fps, 1);
|
||||
frequencySpectrum(signal_2, fps, 1, RoI);
|
||||
% 2nd part of the signal with 0.5 Hz resolution
|
||||
frequencySpectrum(signal_2, fps, 0.5);
|
||||
frequencySpectrum(signal_2, fps, 0.5, RoI);
|
||||
|
||||
|
||||
|
||||
|
|
@ -63,15 +66,15 @@ frequencySpectrum(signal_2, fps, 0.5);
|
|||
%plots power spectrum with blackman window
|
||||
signal_1_win = blackmanWin(signal_1);
|
||||
% 1st part of the signal with 1 Hz resolution
|
||||
frequencySpectrum(signal_1_win, fps, 1);
|
||||
frequencySpectrum(signal_1_win, fps, 1, RoI);
|
||||
% 1st part of the signal with 0.5 Hz resolution
|
||||
frequencySpectrum(signal_1_win, fps, 0.5);
|
||||
frequencySpectrum(signal_1_win, fps, 0.5, RoI);
|
||||
|
||||
signal_2_win = blackmanWin(signal_2);
|
||||
% 2nd part of the signal with 1 Hz resolution
|
||||
frequencySpectrum(signal_2_win, fps, 1);
|
||||
frequencySpectrum(signal_2_win, fps, 1, RoI);
|
||||
% 2nd part of the signal with 0.5 Hz resolution
|
||||
frequencySpectrum(signal_2_win, fps, 0.5);
|
||||
frequencySpectrum(signal_2_win, fps, 0.5, RoI);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue