2020-11-26 15:14:39 +00:00
|
|
|
%% Inicialização do ambiente
|
|
|
|
clear ; close all; clc
|
|
|
|
|
|
|
|
%% Exercício 2
|
|
|
|
sintetico_data = fopen('sintetico.csv');
|
|
|
|
sintetico = textscan(sintetico_data, '%f', 'Delimiter', ',');
|
|
|
|
sintetico = sintetico{1,1};
|
|
|
|
fclose(sintetico_data);
|
|
|
|
cello = importdata('cello.mat');
|
|
|
|
EEG = importdata('EEG.mat');
|
|
|
|
EEG = EEG';
|
|
|
|
|
2020-11-26 16:04:32 +00:00
|
|
|
% sinal sintetico
|
|
|
|
Ls = length(sintetico);
|
|
|
|
Ts = 0.125;
|
|
|
|
Fs = 1/Ts;
|
|
|
|
Fs_vector = (0:Ls-1)/Ls * Fs;
|
|
|
|
|
|
|
|
% sinal cello
|
|
|
|
Lc = length(cello.x);
|
|
|
|
Tc = cello.dt;
|
|
|
|
Fc = 1/Tc;
|
|
|
|
Fc_vector = (0:Lc-1)/Lc * Fc;
|
|
|
|
|
|
|
|
% sinal EEG
|
|
|
|
Le = length(EEG);
|
|
|
|
Fe = 100;
|
|
|
|
Fe_vector = (1:Le-1)/Le * Fe;
|
2020-11-26 15:14:39 +00:00
|
|
|
|
|
|
|
figure(1)
|
|
|
|
|
|
|
|
subplot(2,1,1)
|
|
|
|
plot(sintetico);
|
|
|
|
title('sinal sintetico');
|
|
|
|
|
|
|
|
subplot(2,1,2)
|
2020-11-26 16:04:32 +00:00
|
|
|
DFT_synth = fft(sintetico, Ls);
|
|
|
|
plot(Fs_vector, abs(DFT_synth))
|
2020-11-26 15:14:39 +00:00
|
|
|
xlabel('\omega/\pi'), ylabel('|X(\omega)|'), title('DFT sintetico em [0, \pi]')
|
|
|
|
|
|
|
|
figure(2)
|
|
|
|
|
|
|
|
subplot(2,1,1)
|
|
|
|
plot(cello.x);
|
|
|
|
title('sinal cello');
|
|
|
|
|
|
|
|
subplot(2,1,2)
|
2020-11-26 16:04:32 +00:00
|
|
|
DFT_cello = fft(cello.x, Lc);
|
|
|
|
plot(Fc_vector, abs(DFT_cello))
|
2020-11-26 15:14:39 +00:00
|
|
|
xlabel('\omega/\pi'), ylabel('|X(\omega)|'), title('DFT cello em [0, \pi]')
|
|
|
|
|
|
|
|
figure(3)
|
|
|
|
|
|
|
|
subplot(2,1,1)
|
|
|
|
plot(EEG);
|
|
|
|
title('sinal EEG');
|
|
|
|
|
|
|
|
subplot(2,1,2)
|
2020-11-26 16:04:32 +00:00
|
|
|
DFT_EEG = fft(EEG, Le-1);
|
|
|
|
plot(Fe_vector, abs(DFT_EEG))
|
2020-11-26 15:14:39 +00:00
|
|
|
xlabel('\omega/\pi'), ylabel('|X(\omega)|'), title('DFT EEG em [0, \pi]')
|
|
|
|
|
|
|
|
|
|
|
|
function f = X(N, inicio, fim)
|
|
|
|
f = (0:(1/N):(1 - 1/N))*(fim-inicio)+inicio;
|
|
|
|
end
|