Create a text file and writing a 2D list into it.

1 回表示 (過去 30 日間)
Isaac Mussali M
Isaac Mussali M 2019 年 10 月 21 日
回答済み: Sid Singh 2019 年 10 月 24 日
Hello there! I have two variables (X and Y) each containing a thousand elements in the form 1x1000. My goal is to create a text file that looks like this:
X---------------------------------Y
x1 y1
x2 y2
x3 y3
x4 y4
and so on and so on
I´ve tried with the following code:
resultadosreto=fopen('resultadosreto.txt','w');
fprintf(resultadosreto,'X-------------------Y\n');
fprintf(resultadosreto,'%2.2f %4.3f\n',pfinalx,pfinaly);
However, MATLAB creates a text file like this
X---------------------------------Y
x1 x501
x2 x502
x3 x503
.....until 500 until a 1000
x500 x1000
then it prints the list on variable Y in the same format.
Any help would be appreciated!
  1 件のコメント
darova
darova 2019 年 10 月 22 日
Please attach the data

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

回答 (1 件)

Sid Singh
Sid Singh 2019 年 10 月 24 日
Hi, if we see the data, we can give more inputs. In the meanwhile, can you please try to iterate over pfinalx and pfinaly and use fprintf to write each line one by one?

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by