how fined vector index
이전 댓글 표시
I have a vector of 60,000 x 1, each part containing the values 0-9
What do I need to do to find out in which cells, for example, the value is 1?
The goal is to have an index of cells equal to 1
댓글 수: 4
Athrey Ranjith Krishnanunni
2021년 1월 18일
myVector = randi([0,9],60e3,1); % vector of 60,000x1 containing integers between 0 and 9
linearIdx = find(myVector == 1); % linear indices of elements equal to 1
You might also want to look at ind2sub if you plan to not just limit to vectors.
Also, most applications support logical indexing, which is faster and uses less memory than linear indexing, so maybe look that up too.
lech king
2021년 1월 18일
Jan
2021년 1월 19일
@ARK: Please post this as an answer, not as a comment. Then we can vote for it and select it as accepted asnwer.
Athrey Ranjith Krishnanunni
2021년 1월 20일
@Jan I didn't know whether OP wanted a more complicated solution, so I just suggested this simplified version to see if it'll serve their purpose. I'll put it up as the answer.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!