New signal, RoI and changed frequency
This commit is contained in:
parent
56aeabf968
commit
f7d365a5d1
|
|
@ -1,4 +1,4 @@
|
||||||
function power = frequencySpectrum(signal, fs, resolution)
|
function power = frequencySpectrum(signal, fs, resolution,RoI)
|
||||||
%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%
|
||||||
%function power = frequencySpectrum(signal, fs, pad)
|
%function power = frequencySpectrum(signal, fs, pad)
|
||||||
%
|
%
|
||||||
|
|
@ -8,6 +8,7 @@ function power = frequencySpectrum(signal, fs, resolution)
|
||||||
% - signal: the input signal to process
|
% - signal: the input signal to process
|
||||||
% - fs: the sampling rate in Hz
|
% - fs: the sampling rate in Hz
|
||||||
% - resolution: frequency resolution in Hz, signal will be padded with zeros if necessary
|
% - resolution: frequency resolution in Hz, signal will be padded with zeros if necessary
|
||||||
|
% - RoI: region of interest
|
||||||
%
|
%
|
||||||
% Output:
|
% Output:
|
||||||
% - power: the power spectrum
|
% - power: the power spectrum
|
||||||
|
|
@ -52,12 +53,14 @@ subplot(1,3,2) % linear frequency plot
|
||||||
f = (0:n-1)*(fs/n); % frequency range
|
f = (0:n-1)*(fs/n); % frequency range
|
||||||
plot(f,power, 'b*'); hold on;
|
plot(f,power, 'b*'); hold on;
|
||||||
plot(f,power, 'r');
|
plot(f,power, 'r');
|
||||||
|
xlim(RoI);
|
||||||
title("Frequency Linear ");
|
title("Frequency Linear ");
|
||||||
xlabel('Frequency (Hz)')
|
xlabel('Frequency (Hz)')
|
||||||
ylabel('Power (a.u.)')
|
ylabel('Power (a.u.)')
|
||||||
|
|
||||||
subplot(1,3,3) % log frequency plot
|
subplot(1,3,3) % log frequency plot
|
||||||
plot(f,10*log10(power/power(ind)));
|
plot(f,10*log10(power/power(ind)));
|
||||||
|
xlim(RoI);
|
||||||
title("Frequency Log");
|
title("Frequency Log");
|
||||||
xlabel('Frequency (Hz)')
|
xlabel('Frequency (Hz)')
|
||||||
ylabel('Power (dB)')
|
ylabel('Power (dB)')
|
||||||
|
|
|
||||||
7
main.m
7
main.m
|
|
@ -1,6 +1,6 @@
|
||||||
%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%
|
||||||
% UNKNOWN SIGNAL
|
% UNKNOWN SIGNAL
|
||||||
% Sampling frequency: 300 Hz
|
% Sampling frequency: 200 Hz
|
||||||
% Duration; 2 s
|
% Duration; 2 s
|
||||||
% First second: 0.1Hz, 30 Hz, 30.5 Hz, 60 Hz, 61 Hz
|
% 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
|
% Second second: 0.1Hz, 32 Hz, 36 Hz, 64 Hz, 72 Hz
|
||||||
|
|
@ -14,7 +14,7 @@ signal = csvread('unknownsignal.csv');
|
||||||
|
|
||||||
%%%%%SIGNAL CHARACTERISTICS%%%%%
|
%%%%%SIGNAL CHARACTERISTICS%%%%%
|
||||||
% sets sampling frequency
|
% 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
|
% computes the duration of the signal
|
||||||
duration = length(signal) / fps; % in s
|
duration = length(signal) / fps; % in s
|
||||||
|
|
@ -22,6 +22,9 @@ duration = length(signal) / fps; % in s
|
||||||
% estimates its original frequency resolution
|
% estimates its original frequency resolution
|
||||||
resolution = fps / length(signal); % in Hz
|
resolution = fps / length(signal); % in Hz
|
||||||
|
|
||||||
|
%crop the Power spectrums over the region of interest
|
||||||
|
RoI=[5,20];
|
||||||
|
|
||||||
%%%%%STATIONARITY%%%%%
|
%%%%%STATIONARITY%%%%%
|
||||||
% temporal plot
|
% temporal plot
|
||||||
figure;
|
figure;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue