matlab - Saving results Sequence wise in .dat format -
i seek save results in .dat format sequence wise increasing name. end in wrong format/file name.
1st loop result cm_clusters_2=[ 0.0293650000000000 0.0562520000000000] 2nd loop result cm_clusters_2=[ 0.0293650000000000 0.0562520000000000; 0.0293650000000000 0.0562520000000000] 3rt loop result cm_clusters_2=[ 0.0293650000000000 0.0562520000000000; 0.0293650000000000 0.0562520000000000; 0.0293650000000000 0.0562520000000000] . . . 10th loop result cm_clusters_2= [0.0293650000000000 0.0562520000000000; 0.0293650000000000 0.0562520000000000; 0.0293650000000000 0.0562520000000000; 0.0293650000000000 0.0562520000000000; 0.0293650000000000 0.0562520000000000; 0.0293650000000000 0.0562520000000000; 0.0293650000000000 0.0562520000000000; 0.0293650000000000 0.0562520000000000; 0.0293650000000000 0.0562520000000000; 0.0293650000000000 0.0562520000000000]
sequence numbering format:
if(kk<10) file_number = ['0000' int2str(kk)]; elseif(kk>=10 && kk<100) file_number = ['000' int2str(kk)]; elseif(kk>=100 && kk<1000) file_number = ['00' int2str(kk)]; elseif(kk>=1000 && kk<10000) file_number = ['0' int2str(kk)]; end
i seek these 3 formats changing saving file name in 1st format file save under name of "particles_file_name" , other or not working
if kk~=1 particles_file_name = ['cm_clusters_2_' file_number.dat]; save particles_file_name cm_clusters_2 -ascii ; end
2nd format
if kk~=1 particles_file_name = ['cm_clusters_2_' file_number]; save particles_file_name.dat cm_clusters_2 -ascii ; end
3rd format
if kk~=1 save ( ['cm_clusters_2_' file_number.dat] cm_clusters_2 -ascii ; end
any command line can save info file in .dat format , sequence wise increment in saving file name.
from past question not want sequence file name updated why write question info resuts saved in under same name("particles_file_name") not appropriate results. sequence save of .dat files in matlab
try formatting strings sprintf
particles_file_name = sprintf('cm_clusters_2_%05d.dat', kk ); save( particles_file_name, '-ascii', 'cm_clusters_2' );
the format string '%05d'
give int @ to the lowest degree 5 digits padded zeros if kk
has less 5 digits.
you might want consider replacing int2str
num2str
allows format string
file_number = num2str( kk, '%05d' );
againg, using same format string.
matlab
No comments:
Post a Comment