フィルターのクリア

Changing portions of variable names

1 回表示 (過去 30 日間)
Noah Wilson
Noah Wilson 2019 年 7 月 1 日
編集済み: Stephen23 2019 年 7 月 1 日
This may be a very simple question but I have been struggling with it for a bit and would appreciate the help.
rawdatafile = dir('*.csv');
rawdata = rawdatafile.name;
RawDataMatrix = csvread(rawdata, 13,0);
dlmwrite( strcat(rawdata,'.dat'), RawDataMatrix)
I have some code that finds a .csv file and imports it then deletes the first 13 rows and I am wanting to save the matrix as the same filename except instead of .csv I want to save it as .dat. The current code I have above saves it as filename.csv.dat so I am wondering how to get rid of the '.csv' portion before I save it. Thanks for the help!

採用された回答

Stephen23
Stephen23 2019 年 7 月 1 日
編集済み: Stephen23 2019 年 7 月 1 日
Use this as the new filename:
strrep(rawdata,'.csv','.dat')
Or more robustly:
[~,fnm] = fileparts(rawdata);
sprintf('%s.dat',fnm)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by