How to calculate post-pre connectivity matrices for multiple subjects

1 vue (au cours des 30 derniers jours)
newbie
newbie le 2 Août 2019
Modifié(e) : KSSV le 2 Août 2019
Hi all,
I am a newbie in MATLAB and desperately need help. I have connectivity matrices (51x51) for 33 subjects for pre_intervention and post_intervention scans.
I would like to group all the 33 pre_intervention matrices and 33 post_intervention matrices, then calculate:
Gnew= Gpost- Gpre
And run a paired t-test.
The filenames are saved in this format: ABC_MS001_post_taskA_connectivity.mat
ABC_MS001_pre_taskA_connectivity.mat
ABC_MS002_post_taskA_connectivity.mat
ABC)MS002_pre_taskA_connectivity.mat
How can I load the concatenated Gpre to be subtracted from the concatenated Gpost .mat files?

Réponses (1)

KSSV
KSSV le 2 Août 2019
Modifié(e) : KSSV le 2 Août 2019
postfiles = dir('*post*.mat') ; m = length(postfiles) ;
prefiles = dir('*pre*.mat') ; n = length(prefiles) ;
post = zeros(51,51,m) ;
pre = zeros(51,51,n) ;
for i = 1:m % as you said both the files are same in number so one loop
load(postfiles(i).name) ;
post(:,:,i) = Gpost ; % name the matrix in the mat file
pre(:,:,i) = Gpre ; % name the matrix in the mat file
end
Gnew= Gpost- Gpre ;

Catégories

En savoir plus sur Creating and Concatenating Matrices 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