How to find the frequency of individual elements in a matrix?
조회 수: 4 (최근 30일)
이전 댓글 표시
How do I find the frequencies of all the elements in the matrix attached and also draw a histogram knowing the frequencies of the elements?
댓글 수: 0
채택된 답변
Dyuman Joshi
2024년 4월 4일
편집: Dyuman Joshi
2024년 4월 4일
MATLAB has a in-built function for it - histogram, which does both the operations in single command -
s = load('micro2d (2).mat')
vec = s.Expression1(:).';
val = unique(vec);
h = histogram(vec, [val Inf])
%numbers
val
%corresponding frequencies
freq = h.Values
댓글 수: 0
추가 답변 (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!