How can I plot two different columns in a single matrix without mixing them, using fprintf?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Amal Eleonora Mahajneh
am 19 Feb. 2018
Beantwortet: Venkata Siva Krishna Madala
am 22 Feb. 2018
Hi, can you help me please? I'm trying to print two columns. This is my code
b=[1; 2; 3; 4];
c=[b b];
test=fopen('prova.txt','w');
fprintf(test,'%f %d\n', c);
fclose(test);
I'd like to see it this way
1.000000 1
2.000000 2
3.000000 3
4.000000 4
but I get
1.000000 2
3.000000 4
1.000000 2
3.000000 4
Could you please help me?
Thank you very much.
Amal
0 Kommentare
Antworten (1)
Venkata Siva Krishna Madala
am 22 Feb. 2018
Hello Amal,
After analyzing your code I realized that you have not properly stored the data in c (Wrong Order). You have to understand that fprintf function writes the data column wise and hence store the data in that order itself.
b=[1 2 3 4];
c=[b; b];
test=fopen('prova.txt','w');
fprintf(test,'%f %d\n', c);
fclose(test);
-Venkata Siva Krishna Madala
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!