フィルターのクリア

How to read and write a matrix in/from a file on MATLAB?

1 回表示 (過去 30 日間)
Rahim Rahim
Rahim Rahim 2020 年 12 月 12 日
回答済み: Image Analyst 2020 年 12 月 12 日
Let's we assume that, I have a matrix :
%A=[M,N];
A=[ 5 5 5 5 5 55 5 55 5 ]
, I want to save A in a file TXT. and I can't open that file another time. Also I can modify that file, for example A=A*5;
I did not find the code.

回答 (1 件)

Image Analyst
Image Analyst 2020 年 12 月 12 日
Why can't you open it at another time? How did you write it? Did you use writematrix() or csvwrite()? Or did you use fprintf() but forgot to call fclose():
fid = fopen('TXT.txt', 'wt');
fprintf(fid, '%d ', A);
fclose(fid); % You need this, otherwise MATLAB MAY have a lock on it and other programs won't be able to open it.

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by