read several csv files with space in the name format
    2 次查看(过去 30 天)
  
       显示 更早的评论
    
Hi 
I am trying to read several csv file
opt.w.matrix.reg. 1 ( please note there is space between . and 1 ) 
opt.w.matrix.reg. 2
:
: 
etc 
In order to do that I used first the following :
filename2 = strcat('opt.w.matrix.reg. ',int2str(i),'.csv')
However when I display the file name I received :     opt.w.matrix.reg.1 
the name does not contain space between the . and the number 1 while the original files have this space.
 How can I edit the syntax to have the space in the name.
0 个评论
采纳的回答
  Les Beckham
      
 2023-4-12
        i = 1;
filename2 = strcat('opt.w.matrix.reg. ',int2str(i),'.csv')
As you have seen, strcat strips leading and trailing spaces.  Use sprintf instead.
filename3 = sprintf('opt.w.matrix.reg. %d.csv', i)
更多回答(0 个)
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!