Displaying arrays alongside fprintf() text.

2 ビュー (過去 30 日間)
Louis Grainger
Louis Grainger 2021 年 4 月 20 日
回答済み: Star Strider 2021 年 4 月 20 日
Given an array, say 5x5 populated with 0's
0 0 0 0 0
0 0... so on
Using disp(array) you are unable to define the spaces between elements so the output is rectangular when the data can be ideally mapped in a square. Is there an addition to this function that allows you to change amount of spaces inbetween the elements?
Additionally is there a way to have a fprintf() string alongside the array?
Something lookig like this displayed in the command window:
A B C D E
A 0 0 0 0 0
B 0 0 0 0 0
C 0 0 0 0 0
D 0 0 0 0 0
E 0 0 0 0 0

採用された回答

Star Strider
Star Strider 2021 年 4 月 20 日
Try this:
A = zeros(5);
TA = array2table(A, 'VariableNames',num2cell('A':char('A'+size(A,2)-1)), 'RowNames',num2cell('A':char('A'+size(A,1)-1)))
TA = 5×5 table
A B C D E _ _ _ _ _ A 0 0 0 0 0 B 0 0 0 0 0 C 0 0 0 0 0 D 0 0 0 0 0 E 0 0 0 0 0
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by