File Exchange

image thumbnail

onoffids2logical(on​OffIds, varargin)

version (2.55 KB) by David J. Mack
Convert start and end ids of events to logical indicator array.


Updated 27 Apr 2017

View License

This is a utility function to compute a logical indicator array from the start and end ids of events in an array, e.g. 4/5 & 7/10 -> 00011011110. This is can be used quickly extract the events by logical indexing. It is vectorized and thus is very fast even for large arrays.
This function is part of a set of functions to convert between logical and number indexing in arrays:

Comments and Ratings (0)


- [ADD] Error check for onOffIds outside of prespecified n.
- [FIX] Disappearing single sample events.

2016-12-16 (DJM): [FIX] Removed enlarging 'IsOn' in case the last sample is contained in 'OnOffIds'.

Added links.

MATLAB Release Compatibility
Created with R10
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor