How do plot rows of your matrix into a histogram?
조회 수: 11 (최근 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!