matlab - How to select rows from a matrix -


i beginner in matlab. saving file using,

eval(['save(''results/loc_', num2str(location) ,''',''values'')']); 

i have 54 locations. in case save 54 files named loc_1,loc_2...loc_54 in new folder named 'results'. size of each file 15x7. in case number of columns remain same. number of rows change. if take 1 trial,then 'loc_1' give 3x7 values. if take 2 trials, 'loc_1' give 6x7 values , on. in case want take 'trial' variable , value 5. each file named loc_1,loc_2,..,loc_54 give me 15x7 values.

now want separate first 5 rows (and 7 columns) loc_1 , need save them in 3 different files , size of each file 5x7. have save loc_numstr(location) files (that total of 54 files) , separate them this. have 3 sets of 54 files of each size 5x7. in case taking 5 trials, separating 5x7 size of each file. 4 trials, need consider 4x7 , on.

any kind of appreciated. thanks.

i think made bit complicated. can explain me example please?

i want ask if have matrix example : a=[1 2 3 ; 1 3 4 ; 4 5 7 ; 9 10 12 ; 13 16 18 ; 22 26 29]

and how take first 2 rows , save them in file, next 2 rows , save them in file , next 2 rows , save them in file?

for example, want store b= [1 2 3 ; 1 3 4 ] , c= [4 5 7 ; 9 10 12 ] , d= [13 16 18 ; 22 26 29]

thanks

for example, can use array slicing,

a=[1 2 3 ; 1 3 4 ; 4 5 7 ; 9 10 12 ; 13 16 18 ; 22 26 29] n = 1:3    %indices matrix section    j = 2*n; = j-1;    %get matrix section save    b = a(i:j,:)    save(['results/loc_',num2str(n)], 'b') end 

i'm not sure save want -- saves matlab workspace variables. did want write numbers can read other program?


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -