This commit is contained in:
Adrien COMBE 2023-07-19 15:42:16 +02:00
parent 296d5649ae
commit a95c8aaf4d
1 changed files with 52 additions and 0 deletions

52
SignalFFT.m Normal file
View File

@ -0,0 +1,52 @@
#Date: 19/07/2023
#Author: Adrien COMBE
#Description: Retake exam Signal Processing
% Load the CSV file containing the signal
signal = csvread('unknownsignal.csv');
% Given sampling frequency Fs = 650 Hz
Fs = 650;
% Time vector
t = (0:length(signal)-1) / Fs;
% Plot the signal in the time domain
figure;
plot(t, signal);
xlabel('Time (s)');
ylabel('Amplitude');
title('Mysterious Signal in Time Domain');
% Compute the length of the signal
N = length(signal);
% Perform the Fast Fourier Transform (FFT)
fft_result = fft(signal);
% Compute the frequency axis for the FFT plot
f = (0:N-1) * Fs / N;
% Plot the magnitude spectrum of the signal
figure;
plot(f, abs(fft_result));
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Magnitude Spectrum (FFT) of Mysterious Signal');
% Identify the dominant frequencies (sine wave components)
% Set a threshold to filter out noise
threshold = 50;
% Find the indices of dominant frequencies above the threshold
dominant_indices = find(abs(fft_result) > threshold);
% Extract the dominant frequencies and their magnitudes
dominant_frequencies = f(dominant_indices);
dominant_magnitudes = abs(fft_result(dominant_indices));
% Display the dominant frequencies and their magnitudes
disp('Dominant Frequencies (Hz):');
disp(dominant_frequencies);
disp('Magnitudes:');
disp(dominant_magnitudes);