I have a matrix of dimension 180x41 double. First column of the matrix is SubjectID, rest columns are four scores for 10 segments. I need to calculate mean of four scores for each part and store in one matrix. Please Help!

1 vue (au cours des 30 derniers jours)
The output should look like as:
SUbID MSE1_S1(Mean) MSE2_S2(Mean) MSE3_S3(Mean)...... where MSE1_S1 = mean(MSE_1_S1,MSE_1_S2,MSE_1_S3,MSE_1_S4)

Réponse acceptée

KL
KL le 31 Août 2017
data = dlmread('MSE_cl_Fz.csv',',',1,2);
ind_s = 1:4:size(data,2);
ind_e = 4:4:size(data,2);
for row_no = 1:size(data,1)
mean_arr(row_no,:) = arrayfun(@(a,b) mean(data(row_no,a:b)),ind_s,ind_e);
end

Plus de réponses (2)

Jan
Jan le 31 Août 2017
Modifié(e) : Jan le 31 Août 2017
Or:
s = size(data);
data = reshape(data, [s(1), 4, s(2) / 4]);
mean4 = squeeze(mean(data, 2));
  1 commentaire
Bubblesjinx
Bubblesjinx le 31 Août 2017
Now, I have to apply trapz function to each row ; and make a final matrix which contains sub_ID and AUC score!

Connectez-vous pour commenter.


KSSV
KSSV le 31 Août 2017
IT is a straight forward job....Read about xlsread and mean .
xlsread load the data to matlab and mean calculates your mean.
  1 commentaire
Bubblesjinx
Bubblesjinx le 31 Août 2017
Thanks for your answer. May be my question wasn't clear. I need to make a loop to iterate through rows (180 rows) and each row should calculate mean of four values (MSE_1_S1 to MSE_4_S1 = mean of these four values and there are 40 like them) and store in one matrix.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by