This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
DSP/TP3/DiogoEliseu_TP3_2.m

73 lines
1.7 KiB
Mathematica
Raw Normal View History

2020-11-26 15:14:39 +00:00
%% Inicialização do ambiente
2020-12-14 03:10:51 +00:00
clear; close all; clc
2020-11-26 15:14:39 +00:00
%% 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';
% sinal sintetico
Ls = length(sintetico);
Ts = 0.125;
Fs = 1/Ts;
2020-12-14 02:53:08 +00:00
Fs_vector = linspace(0, 2*pi*Fs, Ls)/(pi*Fs);
Fs_vector_pi = Fs_vector(1:(length(Fs_vector)/2));
% sinal cello
Lc = length(cello.x);
Tc = cello.dt;
Fc = 1/Tc;
2020-12-14 02:53:08 +00:00
Fc_vector = linspace(0, 2*pi*Fc, Lc)/(pi*Fc);
Fc_vector_pi = Fc_vector(1:(length(Fc_vector)/2));
% sinal EEG
Le = length(EEG);
Fe = 100;
2020-12-14 02:53:08 +00:00
Fe_vector = linspace(0, 2*pi*Fe, Le)/(pi*Fe);
Fe_vector_pi = Fe_vector(1:(length(Fe_vector)/2));
2020-11-26 15:14:39 +00:00
figure(1)
subplot(2,1,1)
plot(sintetico);
2020-12-10 14:21:46 +00:00
xlabel('t'), ylabel('sintetico[t]'), title('sinal sintetico');
2020-11-26 15:14:39 +00:00
subplot(2,1,2)
DFT_synth = fft(sintetico, Ls);
2020-12-03 10:49:38 +00:00
DFT_synth_pi = DFT_synth(1 : (Ls)/2);
2020-12-14 02:53:08 +00:00
plot(Fs_vector_pi, abs(DFT_synth_pi))
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);
2020-12-10 14:21:46 +00:00
xlabel('t'), ylabel('cello[t]'), title('sinal cello');
2020-11-26 15:14:39 +00:00
subplot(2,1,2)
DFT_cello = fft(cello.x, Lc);
2020-12-03 10:49:38 +00:00
DFT_cello_pi = DFT_cello(1 : (Lc)/2);
2020-12-14 02:53:08 +00:00
plot(Fc_vector_pi, abs(DFT_cello_pi))
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);
2020-12-10 14:21:46 +00:00
xlabel('t'), ylabel('eeg[t]'), title('sinal EEG');
2020-11-26 15:14:39 +00:00
subplot(2,1,2)
2020-12-14 02:53:08 +00:00
DFT_EEG = fft(EEG, Le);
DFT_EEG_pi = DFT_EEG(1 : (Le)/2);
plot(Fe_vector_pi, abs(DFT_EEG_pi))
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;
2020-12-14 03:10:51 +00:00
end