MATLAB: How to introduce a ‘ \ ‘ after ‘ sprintf ‘

slash after sprintf function

Hello
I have a problem introducing a slash after 'sprintf' function
My code is this:
folderName1='Image_%d_TrueColor_Segmentation';
mkdir('C:\Software\AUTOMATED RESULTS\Segmented_Images',sprintf(folderName1,Num_Exe));
ab=['C:\Software\Segmented_Images\',sprintf(folderName1,Num_Exe)];
My problem occurs as I am trying to introduce a '\' after the path of 'ab' variable. I tried to intriduce it in the 'folderName1' variable at the end but did not work.
Any ideas ???
Thank you in advance

Best Answer

Either use \\ or insert the backslashes as string input:
sprintf('String\\backslashes\\OtherString')
sprintf('String%sOtherString', '\backlash\')
This is explained in "help sprintf". Whenever you have a problem with a specific command, reading the help and doc is recommended.
But for your problem the command fullfile would be more reliable. For details, see "help fullfile".