How to find the histogram of each row vector from 8-by-10000 matrix?

7 ビュー (過去 30 日間)
BIPIN SAMUEL
BIPIN SAMUEL 2022 年 12 月 5 日
編集済み: the cyclist 2022 年 12 月 5 日
I have a matrix 8-by-10000, and want to find the histogram of each row matrix (1-by-10000). I have used tis code:
K=8
for h=1:K
hist(h,:)=histogram(u(h,:));
end
But using this code; gave me 'hist' as 8-by-1 cell. When I accessed for values, it is showing 'Invalid or deleted object'. How can I get the values and properties of the resultant histogram? Also, in my application number of rows of the matrix may vary, so I cannot take each rows of the given matrix 'u' to different variables.

回答 (1 件)

the cyclist
the cyclist 2022 年 12 月 5 日
編集済み: the cyclist 2022 年 12 月 5 日
The histogram function is primarily for plotting histograms. As described in that documentation, the output you are getting is the object handle to the histogram. The reason for the 'Invalid or deleted object' message is that because you do not create new figures for each histogram, each one is getting overwritten (and therefore deleted) by the prior one.
It sounds like maybe you actually need the histcounts function instead. That should give the values you need. I suggest you carefully read that documentation, to understand the output you'll be getting.

カテゴリ

Help Center および File ExchangeDenoising and Compression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by