Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,491 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,721 people online right now. Registration is fast and FREE... Join Now!




find() in C++

 
Reply to this topicStart new topic

find() in C++

prads
26 Jan, 2008 - 07:55 PM
Post #1

D.I.C Head
**

Joined: 22 Oct, 2007
Posts: 111


My Contributions
Hello,
I was wondering if the find() function in C++ does the same as that done in MATLAB. In Matlab it is:
I = FIND(X) returns the linear indices corresponding to the nonzero entries of the array X.
Here's what I have to do:

lets assume R[10] = {1,0,2,3,0,9,0,4,5,6} is an array of 10 numbers and Length is 3.........
The Matlab expression is something like this:
index = find(abs(R(Length : Length * 2 - 1)) > 153) ;
Can anyone please tell me the implementation of this in C++.

Thanks,
Prads

This post has been edited by prads: 26 Jan, 2008 - 08:49 PM
User is offlineProfile CardPM
+Quote Post

jjhaag
RE: Find() In C++
26 Jan, 2008 - 08:55 PM
Post #2

me editor am smartastic
Group Icon

Joined: 18 Sep, 2007
Posts: 1,789



Thanked: 2 times
Dream Kudos: 775
Expert In: C,C++

My Contributions
The find function does not exist in C++, at least one that will perform the way you want it to - there is an algorithm named find from <algorithm>, but it will only return a single index, the first occurence of a given value within a range. To have a function that performs similarly to that in MATLAB, you would have to write your own.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 07:41PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month