Creating empty txt file

52 ビュー (過去 30 日間)
Tay
Tay 2021 年 8 月 30 日
コメント済み: Stephen23 2021 年 11 月 24 日
Hi,
I am trying to create an empty text file using the "save" but is not JUST creating the txt file but is filling with random data.
Here is the line in my code.
save(strcat(path_,filename1,'window_temp_',num2str(window_temp),'.txt')); %temp window
window_temp is just a variable.
I just want to save as empty txt with the name window_temp_15, for example. It's just a way of not having to save my code data manually.
Thank you.

採用された回答

Jan
Jan 2021 年 8 月 30 日
編集済み: Jan 2021 年 8 月 30 日
The save() command stores the contents of the current workspace in a MAT file. See:
doc save
To create an empty text file, use fopen():
filename = sprintf('%swindow_temp_%d.txt', filename1, window_temp)
fid = fopen(fullfile(path_, filename), 'w');
fclose(fid)
  1 件のコメント
Tay
Tay 2021 年 8 月 30 日
Hi Jan,
Nice picture ! :D
Thank you.

サインインしてコメントする。

その他の回答 (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