How to align names with the numbers in a matrix?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Karanvir singh Sohal
am 5 Apr. 2021
Bearbeitet: Adam Danz
am 6 Apr. 2021
Hello!
I have to put heading row over the data matrix so I used the following code:
a=[12 13 14];
b={'a'; 'b'; 'c';};
c=[char(b)'; num2str(a)]
it gives me:
C= abc
12 13 14
But I want to align the first row over the second one.
required output:
C= a b c
12 13 14
2 Kommentare
David Fletcher
am 5 Apr. 2021
Can't you use a table - using the entries in b as the VariableNames and a as the row data
Karanvir singh Sohal
am 5 Apr. 2021
Bearbeitet: Karanvir singh Sohal
am 5 Apr. 2021
Akzeptierte Antwort
Karanvir singh Sohal
am 6 Apr. 2021
Weitere Antworten (1)
Walter Roberson
am 5 Apr. 2021
a=[12 13 14];
b={'a'; 'b'; 'c';};
fprintf('%5s %5s %5s\n', b{:}); fprintf('%5d %5d %5d\n', a);
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices 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!