Even though OP says "cells", based on their response to my comment, it seems that they were talking about simple vectors after all. In which case the following code:
myVector = randi([0,9],60e3,1);
linearIdx = find(myVector == 1);
will work (in the second line, 1 can be substituted for whatever number is required).
It would be a good idea to look at ind2sub if you plan to also use matrices (instead of just vectors) some day.
Also, most applications support logical indexing, which is faster and uses less memory than linear indexing, so maybe look that up too.
4 Comments
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719755-how-fined-vector-index#comment_1269430
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719755-how-fined-vector-index#comment_1269430
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719755-how-fined-vector-index#comment_1269625
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719755-how-fined-vector-index#comment_1269625
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719755-how-fined-vector-index#comment_1272074
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719755-how-fined-vector-index#comment_1272074
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719755-how-fined-vector-index#comment_1273779
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/719755-how-fined-vector-index#comment_1273779
Sign in to comment.