How to return index of started specific pattern from array/matr​ix(column/​rows)

1 回表示 (過去 30 日間)
Mohamed Jamal
Mohamed Jamal 2020 年 6 月 28 日
コメント済み: Mohamed Jamal 2020 年 6 月 29 日
Hi guys!
I have vector(matrix column size 1x1500 ) called a, I want to search inside that vector on specific pattern which it's for instance it's ex=[1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0] ;
I want to search through the vector " a " on the pattern ex and if found then return the first index where the pattern ex started inside the vector a.
how can I do that?
what I've done is this:
for i=1:1:size(a)
if(a(i:size(a))==ex)
return i
end
end
but it didn't works .. how can I do that? the vector a might including more than one pattern that Im searching for ... so there would be much indexes returned of all the patterns that found inside the vector a.

回答 (1 件)

Tommy
Tommy 2020 年 6 月 28 日
  2 件のコメント
Mohamed Jamal
Mohamed Jamal 2020 年 6 月 29 日
Hi , I dont want to use already functions .. I want to use for loops and make the implementation manually and not with already built functions .
Mohamed Jamal
Mohamed Jamal 2020 年 6 月 29 日
could you please help me? thanks alot

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by