Hello every body and thanks for your help in advance. i am trying to learn Matlab step by step by reading it's help file. there i read about 'load' function.the problem is i dont know how to save file in .dat form.i searched for it and found sth,but it didn't work. can any body help me please?

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 8 日

0 投票

Look at this example
% How to write a .dat file
A=[1 2 3;4 5 6]
fid=fopen('file1.dat','w')
fwrite(fid, A)
fclose(fid)
% How to read a dat file
fid=fopen('file1.dat','r')
B=fread(fid,[2,3])
fclose(fid)

3 件のコメント

brave owl
brave owl 2013 年 6 月 8 日
thanks alot.good one. but there is a question: the path for the specified file is the current MATLAB one?
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 8 日
You can specify any path you want
fid=fopen('D:\path\file1.dat','w')
brave owl
brave owl 2013 年 6 月 8 日
thanks again:)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で File Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by