Fullfile function gives me a false reading with the slash symbol

조회 수: 3 (최근 30일)
AA
AA 2020년 3월 29일
편집: Stephen23 2020년 3월 30일
fileToRead = fullfile('C:\Users\thomas\Files\' CCC '.csv');
CCC is a string file with CCC='Tax'
I get the following:
C:\Users\thomas\Files\Tax\.csv
but I want the following
C:\Users\thomas\Files\Tax.csv
  댓글 수: 1
Stephen23
Stephen23 2020년 3월 30일
Note to future readers: Peng Li's answer shows the recommended solution.

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

채택된 답변

Peng Li
Peng Li 2020년 3월 29일
fileToRead = fullfile('C:\Users\thomas\Files\', [CCC '.csv']);

추가 답변 (1개)

darova
darova 2020년 3월 29일
Try this
Or you can remove slash symbol
fileToRead(end-5) = [];
  댓글 수: 1
Stephen23
Stephen23 2020년 3월 30일
편집: Stephen23 2020년 3월 30일
There is absolutely no point in doing this:
This answer confuses two different ways of creating the full filename: string concatenation OR using fullfile. It makes absolutely NO sense to combine the two as shown in this answer, which has all of the disadvantages of string concatenation (no automatic handling of the slash/backslash) and only one input to fullfile (thus making it totally superfluous anyway).
I strongly recommend that users read about fullfile before blindly copying this answer.

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

카테고리

Help CenterFile Exchange에서 File Name Construction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by