Matrix manipulation in three numbers

조회 수: 1 (최근 30일)
Tino
Tino 2019년 5월 22일
댓글: James Tursa 2019년 5월 22일
Hello
Please I have 2 numbers in a column that does the same function below
croppedz = z(1:end-mod(end, 2*K), :); %ensure that height of J is a multiple of 2*K by removing extra elements from the end
result = zeros(size(croppedz, 1) / 2 / K, size(croppedz, 2)); %preallocate result
for col = 1:size(croppedz, 2) %loop over the columns. You can't do this without a loop due to the requirement to sort each columns separately
result(:, col) = sum(reshape(sort(croppedz(1:2:end, col)), K, []), 1) ./ sum(reshape(sort(croppedz(2:2:end, col)), K, []), 1); %sort even/odd rows, reshape each into a Kx? matrix, sum across rows and divide the two sums
end
I want to make it 3 numbers instead of two numbers various K as mentioned above for 2 numbers
Kindly get back
Regards
Tino
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 5월 22일
I think we need examples
James Tursa
James Tursa 2019년 5월 22일
(Tino's Answer moved here)
Thanks Walter
for instance I have the following matrices
1 C1
2 C2
2 C1
3 C2
4 C1
5 C2
3 C1
. .
. .
n C3
a matrix that can sort the numbers from lowest to highest and divide from the lowest first three numbers
Lower for k = 3 after sorting
K = C1 + C1+ C1/ C2 + C2 + C2
then down the sorted below when the list is not divisible by 3 it stops at the last number
Hope this is clearer
Tino

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

답변 (0개)

카테고리

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

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by