%0.1x formatting not working for two digits (greater than 9)
3 次查看(过去 30 天)
显示 更早的评论
Alessandro Maria Laspina
2021-2-1
回答: Alessandro Maria Laspina
2021-2-1
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 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!