How we can calculate Power spectrum of EEG signal?

32 views (last 30 days)
Dear all . I want to calculate power spectrum of single channel eeg . I have coded following but it gives error
??? Subscript indices must either be real positive integers or logicals.
Error in ==> modemotion at 17
plot(ff,pp(0:63)); ylabel('power spectrum
density');xlabel('frequency');title('signal power spectrum');
Please give me how i can short out this.
%%%%%Program to calculate the power spectrum of EEG signal%%%%
clear all;
clc;
data=xlsread('C:\Users\SID\Desktop\emotion regulation post2\emotion\shim1.xlsx');
figure(1); xlabel('sample'); ylabel('magnitude'); plot(data);
legend('14 channel plot of subject1 BASELINE');
data= data';
value1=data(1,:);
chan1= value1-mean(value1);
fs=128;d=1/fs;
t=[0:length(chan1)-1]*d;
figure(2);
plot(chan1);title('original signal');
fs=fft(chan1,128);
pp=fs.*conj(fs)/128;
ff=(0:63)/128/d;
figure(3);
plot(ff,pp(0:63)); ylabel('power spectrum density');xlabel('frequency');title('signal power spectrum');
  2 Comments
Star Strider
Star Strider on 6 Sep 2012
%%%%%Program to calculate the power spectrum of EEG signal%%%%
clear all;
clc;
data=xlsread('C:\Users\SID\Desktop\emotion regulation post2\emotion\shim1.xlsx');
figure(1);
xlabel('sample');
ylabel('magnitude');
plot(data);
legend('14 channel plot of subject1 BASELINE');
data= data';
value1=data(1,:);
chan1= value1-mean(value1);
fs=128;
d=1/fs;
t=[0:length(chan1)-1]*d;
figure(2);
plot(chan1);
title('original signal');
fs=fft(chan1,128);
pp=fs.*conj(fs)/128;
ff=(0:63)/128/d;
figure(3);
plot(ff,pp(0:63));
ylabel('power spectrum density');
xlabel('frequency');
title('signal power spectrum');

Sign in to comment.

Answers (2)

Krishnapriya V B
Krishnapriya V B on 23 Sep 2019
%%%%%Program to calculate the power spectrum of EEG signal%%%%
clear all;
clc;
data=xlsread('C:\Users\SID\Desktop\emotion regulation post2\emotion\shim1.xlsx');
figure(1); xlabel('sample'); ylabel('magnitude'); plot(data);
legend('14 channel plot of subject1 BASELINE');
data= data';
value1=data(1,:);
chan1= value1-mean(value1);
fs=128;d=1/fs;
t=[0:length(chan1)-1]*d;
figure(2);
plot(chan1);title('original signal');
fs=fft(chan1,128);
pp=fs.*conj(fs)/128;
ff=(0:63)/128/d;
figure(3);
plot(ff,pp(0:63)); ylabel('power spectrum density');xlabel('frequency');title('signal power spectrum');
  2 Comments
Ashish Tiwari
Ashish Tiwari on 17 Dec 2019
plot(ff,pp( :,1:64)); ylabel('power spectrum density');xlabel('frequency');title('signal power spectrum');
do the minor change in your code and you will get your result just look at the last line and change that to this--->>"plot(ff,pp( : ,1:64)); .indexing was not done properly in your mentioned code

Sign in to comment.


Ashish Tiwari
Ashish Tiwari on 28 Dec 2019
plot(ff,pp( :,1:64)); ylabel('power spectrum density');xlabel('frequency');title('signal power spectrum');
do the minor change in your code and you will get your result just look at the last line and change that to this--->>"plot(ff,pp( : ,1:64)); .indexing was not done properly in your mentioned code

Categories

Find more on EEG/MEG/ECoG in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!