MATLAB Answers

Tino
0

Matrix manipulation in three numbers

Asked by Tino
on 22 May 2019
Latest activity Commented on by James Tursa
on 22 May 2019
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 Comments

I think we need examples
(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

Sign in to comment.

Tags

Products


Release

R2019a

0 Answers


Translated by