Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [m,n]=size(D);
- for i=1:m-1
- if D(i,1)==D(i+1,1)
- D=reshape(D, 2, m/2*n);
- D=(D(i,:)+D(i+1,:))/2;
- D=reshape(D, m/2, n);
- else
- end
- end
- for row=0,row++
- if ( m[row,1] == m[row+1,1])
- {
- mean1 = mean(m[row]);
- mean2 = mean(m[row+1]);
- mean = mean(mean1,mean2);
- }
- end for
- index_row = 1:1:size(D, 1); % linear row index
- index_valid = all(~diff(D(:,1:2)), 2); % valid rows (logical)
- mean_matrix = (D(1:end-1,:) + D(2:end,:))/2; % matrix of all means
- % matrix of valid mean rows only
- mean_matrix_valid = mean_matrix(index_valid,:); % logical index
- % linear index of valid rows, i.e. the pairs indexed (i, i+1)
- index_row_valid = index_row(index_valid); % valid rows (int)
- D = [1 2 3 4 5; 1 1 1 1 1; 1 2 4 4 4; 1 2 3 3 3; 2 2 2 2 2; 2 2 3 3 3];
- >> D =
- 1 2 3 4 5
- 1 1 1 1 1
- 1 2 4 4 4
- 1 2 3 3 3
- 2 2 2 2 2
- 2 2 3 3 3
- >> index_valid =
- 0
- 0
- 1
- 0
- 1
- >> index_row_valid =
- 3 5
- >> mean_matrix_valid =
- 1.0000 2.0000 3.5000 3.5000 3.5000
- 2.0000 2.0000 2.5000 2.5000 2.5000
Add Comment
Please, Sign In to add comment