matlab - Using loops to get multiple values into a cell -
I have 31 topics (S1, S2, S3, S4, etc.) 3 images in each topic, opposite 1 IMG, Contrast 2 IMG and Contrast 3 Are IMG I p In a NX1 cell named P, I would like to use a loop to get all the paths of contrasts from all the subjects:
data / S1 / contrast1.img
/ S1 / contrast2.img
data / S1 / contrast3.img
data / s2 / contrast1.img
data / S2 / contrast2.img < / P>
Data / S2 / contrast3.img ...
Data / S31 / contast3.img
This is what I've tried: < / P>
A = {'S1', 'S2', 'S3', ..., 'S31'}; % All topics C = {'contrast1.img', 'contrast2.img', 'contrast3.img'}; For each = P = cell (31 * 3,1) for each topic, the required contrast images: Length = A for Jammu = 1: Length (C) P {j} = spm_select ('FPList', Fullfile (data_path, q {i}) sprint ('% s', cell2mat (c))); % Of each topic is to select three contrast images, it works in my script, it is probably not 100% correct, because I had to simplify this example. End of End
This, however, only let me drink with 3 opposite pictures of the last subject. The previous topic is overwritten indicating that the loop is wrong, but I'm not sure how to fix it. Can anyone help?
No loop is needed; To use for and without spaces, use:
M = 31; N = 3; [Jaejei] = ndgrid (1: n, 1: m); P = straight ('data / s', 'num2str (ii (:),'% - i), '/ contrast', num2str (jj (:), '% - i'), '.img')
Comments
Post a Comment