Code covered by the BSD License  

Highlights from
findfirst

4.0

4.0 | 1 rating Rate this file 5 Downloads (last 30 days) File Size: 2.33 KB File ID: #2631

findfirst

by Richard Hindmarsh

 

01 Nov 2002 (Updated 18 Jun 2009)

MEX file for finding first or last non-zero.

| Watch this File

File Information
Description

[VALUE,INDEX] = FINDFIRST(A,SEARCHDIR)
Returns the value and optionally index of the first non-zero in A.
A must be full and double
If SEARCHDIR = 'first' (default) the search is from the first index
If SEARCHDIR = 'last', the search is backwards from the last index

This is a cmex file, and is an order of magnitude faster than using FIND, and two orders of magnitude faster than using MATLAB loops.

Tested on Windows NT/2000 VC 6.0, Linux (gcc 2.95) and Solaris (courtesy A Pearson)

MATLAB release MATLAB 6.5 (R13)
Other requirements Needs a C compiler
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
18 Dec 2004 Richard Hindmarsh

The functionality of this routine is in the Matlab FIND command from Version 7

06 Jan 2006 Robert Young

Useful, especially when writing code which must be backwards compatible with MatLab 6.
Had to reverse output arguments to make it more like find.

29 Mar 2007 Vincent Coral

How do I install it? I think I don't have any C compiler actually...Anyone?

Please login to add a comment or rating.
Updates
18 Jun 2009

Changed to BSD license

Tag Activity for this File
Tag Applied By Date/Time
external interface Richard Hindmarsh 22 Oct 2008 06:53:21
find Richard Hindmarsh 22 Oct 2008 06:53:21
mex Richard Hindmarsh 22 Oct 2008 06:53:21
finding Richard Hindmarsh 22 Oct 2008 06:53:21
first Richard Hindmarsh 22 Oct 2008 06:53:21
nonzero Richard Hindmarsh 22 Oct 2008 06:53:21
external code interfacing Richard Hindmarsh 22 Oct 2008 06:53:21

Contact us at files@mathworks.com