Finding elements in table
    4 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Hi guys. I am trying to find a sequence of entries in a vector. The vector is essentially a 1 row by 2114 columns long. The sequence I am trying to find is [3,3,3,-3,-3,-3,-3,3,3,3]. My question is, how do I create a loop that will look for every instance of this sequence of entries?
The first set of that sequence I found was at columns 91-100. In the code, rec1 is the long vector table. I am trying to find the instances of the columns that this happens and display them in another variable/table.
Here is some (bad) code I wrote attempting this:
S = rec1;
preamble1 = rec1(:,91:100);
% user1 = rec1(:,100:110);
disp(pam2letters(S))
for i = S
    if S == rec1(:,91:100);
        x = rec1(:,91:100);
        disp(x)
    else
    end
end
0 件のコメント
採用された回答
  Star Strider
      
      
 2016 年 1 月 15 日
        Amazingly enough, the strfind function works here:
V =  [randi(9, 1, 20) 3,3,3,-3,-3,-3,-3,3,3,3 randi(9, 1, 20)];     % Vector
T = [3,3,3,-3,-3,-3,-3,3,3,3];                                      % Target Sequence
Ix = strfind(V, T);                                                 % Find Start Index Of Target Sequence
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

