フィルターのクリア

why save '.mat' as 'ascii' file appears as FILE instead of txt

26 ビュー (過去 30 日間)
ARP
ARP 2019 年 12 月 5 日
コメント済み: ARP 2019 年 12 月 5 日
Hi,
I am not sure if I saving correclty the variable coefficents_m as text file, since windows does not recognise the file as txt. It can still open with the notepad. The filepath is fine, as I also save the same variable as m.file
name_folder_new =char(app.Name_to_save_data.Value);
mkdir(name_folder_new);
filename1 = fullfile(name_folder_new,'coefficients_m');
save(filename1,'coefficients_m')
save(filename1,'coefficients_m','-ascii')
It is probably something too basic, but I am stuck.
Thanks

採用された回答

Guillaume
Guillaume 2019 年 12 月 5 日
If you want the file to have a .txt extension, then simply tell matlab so:
filename1 = fullfile(name_folder_new,'coefficients_m.txt');
save(filename1,'coefficients_m','-ascii')
Note that a file extension is just a hint to the operating system (and the user) that the file stores a particular type of data. Windows uses the extension to determine which programs to use by default to open the file, but you can open files with any extension with any program as long as the content of the file is in the format expected by the program. Changing the extension of a file does not change what's stored in it.
You could use .ThisIsaTextFile as an extension and still open your text file in notepad (or a better text editor).

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2019 年 12 月 5 日
filename1 = fullfile(name_folder_new,'coefficients_m');
No file extension is put on by default when you do that, so MS Windows does not have the hint to know it is a text file. If you want .txt then specify that as part of the file name.
When you do not use -ascii then a .mat file extension is added by default.
Note: you should check to see whether you want to also use the -double option when you use -ascii

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019 年 12 月 5 日
because the computer has to be guided by the file extension to know what each thing is, all the .mat files are going to open with the default program that you set, therefore, if you set notepad this will appear as a file .mat but that opens with notepad

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by