Create a text file and writing a 2D list into it.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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!
Antworten (1)
Sid Singh
am 24 Okt. 2019
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?
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Import and Export finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!