average selected columns with labels

2 views (last 30 days)
Elaheh on 14 Aug 2020
Commented: KSSV on 14 Aug 2020
hello all,
I have the attached data. It shows a part of my data. I need to average selected coumns in red only. I need to tell matlab that average electrodes such as ChFP1, ChF7, ChF3, and ChFT7, across subjects and write the resluts in one column at the end of data. How should I do that? I wrote this so far. Thank you in advance. I tried to creat a logical index but could not with a cell array.
if exist(fileName,'file')
[num,str]=xlsread(fileName); %read both str and data
ch_lables=(str(1,:)); %electrode lables, cell array
sub_names=str(:,1); %subjects names, cell array
Elaheh on 14 Aug 2020
Thank you,
No, the order of labes is different in each file, so I need to average across lables of channels that are the same in all files, I need to average ChFP1, ChF7, ChF3, ChFT7, ChFC3) and other combination of electrod lables.
I appreicipate your help.

Sign in to comment.

Accepted Answer

KSSV on 14 Aug 2020
Use readtable. This is suggested now.
T = readtable(filename) ;
mean_ChF7 = mean(T.ChF7)
KSSV on 14 Aug 2020
2 stands for mean along each row..this what you wanted. DEfault is 1, which is mean along each column.
NOTE: You have to accept/ vote the answer which worked for you. Not that you comment and accept that. :)

Sign in to comment.

More Answers (0)





Community Treasure Hunt

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

Start Hunting!