BSP Lab
BSP Lab
Code:
x=[0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,
0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1
,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.5,1,0,0.
5,1];
subplot(2,2,1);
plot(x);
xlabel('time');
ylabel('amplitude');
title('eeg');
e=randn(80,1);
subplot(2,2,2);
plot(e);
xlabel('time');
ylabel('amplitude');
title('random noise');
y=conv(x,e);
subplot(2,2,3);
plot(y);
title('nosiy signal');
h=[ones(1,26)]/26;
y1=conv(h,y);
subplot(2,2,4);
plot(y1);
xlabel('time');
ylabel('amplitude');
title('fitered output');
y2=fft(y1);
Figure:
LAB EXERCISE:
Code:
data = csvread('generated_EEG_data.csv', 1, 0);
time = data(:, 1);
eeg_signal = data(:, 2);
figure;
subplot(2,1,1);
plot(time, eeg_signal);
title('Original EEG Signal');
xlabel('Time (s)');
ylabel('Amplitude (\muV)');
Fs = 256;
L = length(eeg_signal);
fft_eeg = fft(eeg_signal);
P2 = abs(fft_eeg/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
subplot(2,1,2);
plot(f, P1);
title('FFT of EEG Signal');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
xlim([0 50]);
Figure: