Count the number of times a particular sequence occurs in the vector.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How to find the number of times and the index a sequence (here 01) occurs in the vector, using for loop?
The vector is randomly generated
A = round(rand(1000,1));
0 Kommentare
Antworten (1)
Bruno Luong
am 15 Nov. 2022
Bearbeitet: Bruno Luong
am 15 Nov. 2022
Not for-loop but it does the job
A=randi(0:1,1,10)
spattern = [0 1];
startidx = strfind(A,spattern)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!