How do plot rows of your matrix into a histogram?
12 ビュー (過去 30 日間)
古いコメントを表示
So usually hist allows you to plot the columns of your matrix into a histogram. i wish to plot the rows. Below is my matrix.
my first column is my ordinal information (so its not counted in the histogram). I also wish to plot for every 2 rows. Is that possible??
0 0.0032 0.0032 0.0032
1.0000 0.0010 0.0028 0.0016
2.0000 0.0012 0.0001 0.0013
3.0000 0.0000 0.0009 0.0025
4.0000 0.0006 0.0000 0.0012
5.0000 0.0006 0.0021 0.0002
6.0000 0.0003 0.0000 0.0003
7.0000 0.0019 0.0016 0.0001
0 件のコメント
回答 (1 件)
Image Analyst
2021 年 11 月 25 日
Not sure what you mean by histogram. Is that your data or some kind of histogram of the data?
Anyway, to plot the rows of your matrix, row-by-row, you can do this:
m=[
0 0.0032 0.0032 0.0032
1.0000 0.0010 0.0028 0.0016
2.0000 0.0012 0.0001 0.0013
3.0000 0.0000 0.0009 0.0025
4.0000 0.0006 0.0000 0.0012
5.0000 0.0006 0.0021 0.0002
6.0000 0.0003 0.0000 0.0003
7.0000 0.0019 0.0016 0.0001];
[rows, columns] = size(m)
for row = 1 : rows
plot(m(row, 2:end), '.-', 'LineWidth', 3, 'MarkerSize', 40)
hold on;
legendStrings{row} = num2str(row);
end
legend(legendStrings)
grid on;
fontSize = 15;
title('m', 'FontSize', fontSize)
xlabel('x', 'FontSize',fontSize)
ylabel('y', 'FontSize',fontSize)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!