필터 지우기
필터 지우기

Splitting matrix and finding mean after each split

조회 수: 1 (최근 30일)
M
M 2012년 12월 17일
This is a follow up to a previous question that I posted.
My actual data is 12x416 matrix. Splitting this data across the median is not a better choice for me. I have to split it across the mean, even if the split is un-even.
So for each row, I find the first mean and then split it in two vectors. Then I find the mean for each vector and again split it. This continues until I have (say) 7 means for each row.
I wrote the following code for 1 row.
% v is a 12x416 matrix
vect1 = v(1, :);
m(1) = mean(vect1)
vect11 = vect1(vect1>m)
vect12 = vect1(vect1<m);
m(2) = mean(vect11);
m(3) = mean(vect12);
vect111 = vect11(vect11>m(2));
vect112 = vect11(vect11<m(2));
vect121 = vect12(vect12>m(3));
vect122 = vect12(vect12<m(3));
m(4) = mean(vect111);
m(5) = mean(vect112);
m(6) = mean(vect121);
m(7) = mean(vect122);
Is there an efficient way to write this all in a loop?
Thanks.
  댓글 수: 3
Walter Roberson
Walter Roberson 2012년 12월 17일
What do you want the output data structure to look like? Do you need all of the intermediate splits, or just the final?
Is it certain than the array is sorted?
M
M 2012년 12월 17일
At the end, I need only those 7 means.
Initially the matrix is not sorted. But I can sort it if needed.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2012년 12월 17일
I'm not sure what you're after but splitting data up into smaller and finer chunks is what quadtree decomposition does. If you have the Image Processing Toolbox, you might take a look at qtdecomp() and see if that does something like what you're trying to do.
  댓글 수: 1
M
M 2012년 12월 17일
편집: M 2012년 12월 17일
What I am looking for is something very similar to k-means clustering. There is a kmeans() in Matlab but it is not exactly what I am looking for. The algorithm is slightly different.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by