read several csv files with space in the name format

조회 수: 8 (최근 30일)
Az.Sa
Az.Sa 2023년 4월 12일
댓글: Les Beckham 2023년 4월 12일
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.

채택된 답변

Les Beckham
Les Beckham 2023년 4월 12일
i = 1;
filename2 = strcat('opt.w.matrix.reg. ',int2str(i),'.csv')
filename2 = 'opt.w.matrix.reg.1.csv'
As you have seen, strcat strips leading and trailing spaces. Use sprintf instead.
filename3 = sprintf('opt.w.matrix.reg. %d.csv', i)
filename3 = 'opt.w.matrix.reg. 1.csv'
  댓글 수: 2
Az.Sa
Az.Sa 2023년 4월 12일
Thank you very much!!
Les Beckham
Les Beckham 2023년 4월 12일
You are quite welcome.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by