LOGICALFIND

Find occurrences of consecutive non-zeros in a vector (v1.0, jan 2014)
311 download
Aggiornato 30 gen 2014

Visualizza la licenza

LOGICALFIND - find occurrences of consecutive non-zeros in a vector

B = LOGICALFIND(V, N) returns the starting indices of any occurrences of N or more consecutive non-zeros in the vector V.
[B, E] = LOGICALFIND(V,N) returns the ending indices as well.
[B, E, CS] = LOGICALFIND(V,N) returns a cell array CS with these occurrences: CS{i} is equal to V(B(i):E(i))

V is (or can be converted to) a binary (logical) vector. N is a scalar integer larger than 0.

Example:
V = logical([0 1 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 1])
B = logicalfind(V,3)
% -> B = [8 15]

X = floor(4*rand(20,1)) % a numerical row vector
[B, E, CS] = logicalfind(X,2)
L = E - B + 1 % length of each occurence
isequal(L, cellfun(@numel,CS)) % check!

See also: find, strfind, regexp

Cita come

Jos (10584) (2024). LOGICALFIND (https://www.mathworks.com/matlabcentral/fileexchange/45305-logicalfind), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2011a
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su Data Type Conversion in Help Center e MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Versione Pubblicato Note della release
1.0.0.0