Finding collumn with specific values within matrix
Afficher commentaires plus anciens
TLDR; looking for a value in the sixth row of a 6x2598960 matrix, if values in the first 5 rows are the same as input.
I have a matrix "ind" of 6x2598960 double
Within the matrix every combination of 52 numbers is contained in the first 5 rows.
With ind(1,n)<ind(2,n)<ind(3,n)<ind(4,n)<ind(5,n)
This results in the 2598960 combinations (binomium of newton: 52*51*50*49*48/24)
My question:
Every collumn has a specific unique rational number attached in the sixth row.
Im trying to figure out a fast algorithm to identify value in the sixth row when looking for a specific 5 number input.
The following script works, but: "Elapsed time is 2.124802 seconds."
This feels long to find a single value in a matrix (allthough the matrix has 15M elements).
v1=[1;2;3;5;4];
v2=sort(v1);
for n=1:2598960
if ind(1,n)==v2(1)
if ind(2,n)==v2(2)
if ind(3,n)==v2(3)
if ind(4,n)==v2(4)
if ind(5,n)==v2(5)
index1=ind(6,n);
end
end
end
end
end
end
Anyone any thoughts on how to to increase the speed to find the value in the sixth row?
1 commentaire
James Tursa
le 16 Avr 2020
Are the ind values sorted in any way?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!