Find complementary column combination of a matrix
Show older comments
Hello! Need your help!
I have a 30x9 matrix A filled with 0, 4, 8.
Get the matrix MaxA where A has its maxima per row:
V = max(A,[ ],2);
MaxA = A==V;
And now i want the indices of the minimum combination of colmuns that gets me a complete column filled with 1, so after all the most complementary columns.
Example:
A = [8 4 0 8 8 [1 0 0 1 1
4 8 0 8 0 MaxA = 0 1 0 1 0
4 0 4 0 0] 1 0 1 0 0]
-> column 1 and 2 of MaxA give me
Result = [1 2 (column 1 and 2)
1 4 (column 1 and 4) -> give me a column with [1; 1; 1]
3 4] (column 3 and 4)
-> column 2, 3 and 5 does the same but i would net 3 instead of 2 columns
Many thanks in advance!!!
Accepted Answer
More Answers (1)
Do you need all combinations or just one of the minimium-length combinations? If the latter, then download minL1intlin
and,
MaxA = [1 0 0 1 1
0 1 0 1 0
1 0 1 0 0];
[m,n]=size(MaxA);
em=ones(m,1);
en=ones(n,1);
Result = find( minL1intlin(speye(n),0*en,1:n,[],[],MaxA,em,0*en,1*en) )'
4 Comments
Bruno Luong
on 16 Apr 2022
Edited: Bruno Luong
on 16 Apr 2022
Careful, OP state (1,4) is a valid solution. Your current formulation can never find such solution since
MaxA*[1; 0; 0; 1; 0] = [2; 1; 1] % and not em
You should specify A, b and not Aeq, beq.
Matt J
on 17 Apr 2022
Careful, OP state (1,4) is a valid solution.
I wonder if that was a mistake..
Bruno Luong
on 19 Apr 2022
Edited: Bruno Luong
on 19 Apr 2022
What nc value returned when there is no admissible solution?
Matt J
on 19 Apr 2022
Whatever intlinprog returns for fval.
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!