convert mat to txt

11 ビュー (過去 30 日間)
Nadi Khosroshahi
Nadi Khosroshahi 2019 年 4 月 12 日
回答済み: Javier Montalt Tordera 2019 年 4 月 12 日
I want to convert a mat file to a txt file with this format:
mat file --> a=[101,10,130,240]
txt file --> 1.101
2.10
3.130
4.240

回答 (1 件)

Javier Montalt Tordera
Javier Montalt Tordera 2019 年 4 月 12 日
The following might help:
fid = fopen('file.txt','w');
for i = 1:length(a)
fprintf(fid,'%d.%d\n',i,a(i));
end
fclose(fid);
This assumes that the numbers in your vector are integers; if this is not true, you might want to use %f instead of %d (after the dot).

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by