Index a small matrix in a larger matrix
2 ビュー (過去 30 日間)
古いコメントを表示
I have larger vector and I need to find if my smaller vector is located inside the larger vector.
A=[2,3,4,1,2,3,4,1,1,2]
x=[1,2]
ismember only returns true wherever it finds either 1 or 2 in the large matrix and I'd rather have a user defined function than ismember.
0 件のコメント
採用された回答
Star Strider
2015 年 3 月 27 日
As strange as it may seem, strfind works here:
A=[2,3,4,1,2,3,4,1,1,2];
x=[1,2];
start_index = strfind(A,x)
produces:
start_index =
4 9
The ‘start_index’ assignment are the start indices of all occurrences of ‘x’ in ‘A’.
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!