Matrix manipulation in three numbers

1 次查看(过去 30 天)
Tino
Tino 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 个评论
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