find a set of data in an array
9 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
I have an array of repetitive values something like A=[0;0;396; ...;140;... ;403; 0 ;0 ;0 ;200; 140; ...;403; 0; 0 ] . I extracted non-zero set of data to another array, called B=[396; ...;140;... ;403 , 200; 140; ...;403]. Now, I want to find the index of each set of elements of array B from array A, but when I use '[tf,idx] = ismember (B,A)' , what is happening is that for those repeated elements the index is always the same as the index of first appeared one (idx for second 140 or 403 is the same of the idx of the first ones!). So, my question is that how can I find the indexes based on order ? or how can I find indexes when all the elements of array B's columns exactly repeated in array A?
Thanks,
Mahsa
1 个评论
Ridwan Alam
2020-1-31
maybe if you share your A and B and some sample code, it would be easier to help.
回答(2 个)
Ridwan Alam
2020-1-31
编辑:Ridwan Alam
2020-1-31
idx = find(A~=0);
B = A(idx);
idx and B have the same size and order. I believe this is what you are looking for?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!