Hello ,
I have this matrix as a result of code :
1,85506173843200 1,00229272121327
1,74935758533076 1,00727718522748
1,54993783446447 1,02899346511808
1,18399896863203 1,18885602705206
and i want to create a txt file named as activity_coefficients.txt which will contain the above matrix as it is.
i use these commands
fileID=fopen('activity_coefficients.txt','w')
fprintf(fileID,'%f\n',gamma)
but the txt file have the above matrix elements one after another.
Can anyone help me ?
Thanks in advance

 採用された回答

Alan Stevens
Alan Stevens 2020 年 9 月 5 日

0 投票

Try this:
gamma =[1.85506173843200, 1.00229272121327;
1.74935758533076, 1.00727718522748;
1.54993783446447, 1.02899346511808;
1.18399896863203, 1.18885602705206];
fID = fopen('activity_coefficients.txt','w');
fprintf(fID,'%16.14g %16.14g \r\n',gamma');
fclose(fID);

1 件のコメント

chntua chntua
chntua chntua 2020 年 9 月 5 日
thanks a lot !!

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

その他の回答 (1 件)

madhan ravi
madhan ravi 2020 年 9 月 5 日

0 投票

writematrix(Gamma, 'activity_coefficients.txt')
%or
dlmwrite('activity_coefficients.txt', Gamma)

1 件のコメント

chntua chntua
chntua chntua 2020 年 9 月 5 日
thank you a lot !

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

カテゴリ

ヘルプ センター および 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