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 Center および File ExchangeFile Name Construction についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by