Finding collumn with specific values within matrix
이전 댓글 표시
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
James Tursa
2020년 4월 16일
Are the ind values sorted in any way?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!