%0.1x formatting not working for two digits (greater than 9)
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alessandro Maria Laspina
el 1 de Feb. de 2021
Respondida: Alessandro Maria Laspina
el 1 de Feb. de 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 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Application Deployment en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!