A grouping vector numbers
1 次查看(过去 30 天)
显示 更早的评论
Hello friends I have one matrix and I need assemble all entries of a matriz in one single vector. This I've done. But I need i need extract repeated values of this and put them in new one. For this I need construct a histogram, and verify which values who not equal to zero and increment a count. So if I find a value not equal to zero I have to increment +1 to value (color) in the histogram position. with intervals100 or 200 to perform small increment in the same "color" (value) on vector
A=[1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0;1 2 3 4 5; 2 3 4 5 5; 6 7 8 9 0]
v = reshape( A.' ,1,numel(A));
0 个评论
回答(2 个)
dpb
2014-6-19
I can't really parse the request but on an off chance it'll help...
BTW, the shortcut for reshape(x,1,[]) is
v=A(:); % this works for all array sizes to generate a column vector
Anyway, as said, taking a guess on the question...
n=histc(v,unique(v));
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!