How do I make a histogram that reports the amount of elements per matrix

2 ビュー (過去 30 日間)
Sterre
Sterre 2019 年 4 月 11 日
コメント済み: Adam Danz 2019 年 4 月 15 日
I have to make a histogram that reports the amount of elements (number of rows) in a matrix, per specific matrix.
My dataset contains 5 matrices (assigned to: rest, u, p, a and k), and I am interested in the amount of rows in every matrix. The first matrix has 63 rows, the second has 49 rows, and so on. See:
trials_rest =
63
trials_u =
49
trials_p =
26
trials_a =
39
trials_k =
60
Now I have to make a histogram where the number of rows (see example) is on the Y axis, and only the titles of the specific matrices (rest, u, p, a, k) are on the X axis. So that I can easily see how many rows every matrix contains.
It has to be easy but I can't seem to figure out how to make this histogram.

採用された回答

Adam Danz
Adam Danz 2019 年 4 月 11 日
編集済み: Adam Danz 2019 年 4 月 11 日
You're describing a bar chart which differs from a histogram.
nRows = [63, 49, 26, 39, 60];
names = categorical({'rest' 'u' 'p' 'a' 'k'});
bar(names, nRows)
ylabel('Number of rows')
xlabel('Matrix name')
190411 122738-Figure 1.jpg
  2 件のコメント
Sterre
Sterre 2019 年 4 月 15 日
Yes, the bar-chart is indeed even a better option in this case! Thank you.
Adam Danz
Adam Danz 2019 年 4 月 15 日
Great! Glad it worked out.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by