%0.1x formatting not working for two digits (greater than 9)
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Alessandro Maria Laspina
le 1 Fév 2021
Réponse apportée : Alessandro Maria Laspina
le 1 Fév 2021
I am meta programming a script file that is to be run on an ssh which runs one instance of matlab for each script. The for loop that prints the name of each file looks like this:
for a=1:10
for b=1:10
write_file=fopen(['TEST' num2str(a) '_' num2str(b) '.m'],'w');
batch_file=fopen(['batch_script_TEST.txt'],'a+');
fprintf(batch_file,['nohup matlab -nodesktop -nosplash -nodisplay <TEST%0.1x_%0.1x.m>& TEST_%0.1x__%0.1x.txt &\n'],a,b,a,b);
fprintf(write_file,out,a,b,a,b,a,b);
fclose('all');
end
end
In the batch_script_TEST.txt file, I get the following result:
nohup matlab -nodesktop -nosplash -nodisplay <launchMainLVLH_01_01.m>& output_6DoFRSCSR_scaling_length_01_scaling_mass_01.txt &
nohup matlab -nodesktop -nosplash -nodisplay <launchMainLVLH_01_02.m>& output_6DoFRSCSR_scaling_length_01_scaling_mass_02.txt &
nohup matlab -nodesktop -nosplash -nodisplay <launchMainLVLH_01_03.m>& output_6DoFRSCSR_scaling_length_01_scaling_mass_03.txt &
nohup matlab -nodesktop -nosplash -nodisplay <launchMainLVLH_01_04.m>& output_6DoFRSCSR_scaling_length_01_scaling_mass_04.txt &
nohup matlab -nodesktop -nosplash -nodisplay <launchMainLVLH_01_05.m>& output_6DoFRSCSR_scaling_length_01_scaling_mass_05.txt &
However, when we approach the 10th value of either the a or b index in the for loops, I get:
nohup matlab -nodesktop -nosplash -nodisplay <launchMainLVLH_01_0a.m>& output_6DoFRSCSR_scaling_length_01_scaling_mass_0a.txt &
The issue is that the the b value, which is supposed to return 10, returns 0a. How can I fix this?
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Application Deployment 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!