How can I export the output data into a ‘*.txt’ file?

31 ビュー (過去 30 日間)
JMS
JMS 2014 年 5 月 1 日
回答済み: Rahul B 2021 年 5 月 12 日
Hi,
How can I export the output data into a ‘*.txt’ file?
"
[x,y] = meshgrid(-5: 4: 5, -5: 4: 5);
x1 = -1;
y1 = 0;
V_x1 = ((y-y1)./((x-x1).^2+(y-y1).^2))
V_x1 = V_x1(:) "
The output data:
"
V_x1 =
-0.1220
-0.0588
0.1200
-0.2000
-1.0000
0.3333
-0.1220
-0.0588
0.1200
"

採用された回答

Geoff Hayes
Geoff Hayes 2014 年 5 月 1 日
Hi JMS,
Just open a file for text writing (wt):
fid = fopen('outputData.txt','wt');
Ensure that the file identifier (fid) is non-zero (else the file couldn't be opened) and use the fprintf command to write each element (if looping) or the complete array/vector:
fprintf(fid,'%.8f\n',V_x1);
Then close the file:
fclose(fid);
Geoff
  1 件のコメント
JMS
JMS 2014 年 5 月 1 日
Thanks Geoff

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

その他の回答 (1 件)

Rahul B
Rahul B 2021 年 5 月 12 日
Hie

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by