フィルターのクリア

how to store the matrix into dat file.

3 ビュー (過去 30 日間)
song
song 2016 年 8 月 5 日
コメント済み: Aiswarya Babu 2021 年 6 月 11 日
Hi,
I have one question about saving the matrix into .dat file. I donot know how to implement it. I will describe the question.
1. I have one matrix c
2. I want to save c into one .dat file in this format:
1 qid:1 1:0.4709 2:0.1948 3:0.2277 4:0.9254
2 qid:1 1:0.2305 2:0.2259 3:0.4357 4:0.4302
3 qid:1 1:0.8443 2:0.1707 3:0.3111 4:0.1848
The elements are separated by a space character Does anybody can help me solve this problem? Thanks so much.

採用された回答

Walter Roberson
Walter Roberson 2016 年 8 月 5 日
fid = fopen('YourFile.dat', 'w');
fprintf(fid, '%d qid:1 1:%6.4f 2:%6.4f 3:%6.4f 4:%6.4f\n', C.');
fclose(fid)
  3 件のコメント
Walter Roberson
Walter Roberson 2016 年 8 月 5 日
The data is not stored in one row: you are using an obsolete editor to look at the file. Microsoft started replacing NotePad by 1997.
If you need to keep using 20 year old software, then replace the 'w' with 'wt'
Aiswarya Babu
Aiswarya Babu 2021 年 6 月 11 日
help me to store data as a text file.
These are the values i need to store as a text file .
29 C3 50 5F 57 14 20 F6 40 22 99 B3 1A 02 D7 3A
Kindly help me.

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 5 日
A=rand(3,5)
fid=fopen('file.dat','w')
fprintf(fid,[repmat('%f ',1,4) '\r\n'],A)
fclose(fid)
  1 件のコメント
song
song 2016 年 8 月 5 日
It is far from what I need. Thank you anyway.

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

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by