Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Find indeces of 1's in logical array
Hi,
I have a logical NxM array. How do I find indeces of elements which are
equal to 1?


Report this thread to moderator Post Follow-up to this message
Old Post
bobrics
06-01-05 02:01 AM


Re: Find indeces of 1's in logical array
the reason I want to do this is because I have a logical statement
which returns NxM logical matrix B  flagging the values from another
numeric matrix A which I need to do operations on.

I want to update values of A at indeces found from B with new values.

I know that A(B), where B is numeric, will do the job. That's why I
want to find indeces of 1's in my logical B array.


Report this thread to moderator Post Follow-up to this message
Old Post
bobrics
06-01-05 02:01 AM


Re: Find indeces of 1's in logical array
On Tue, 31 May 2005 13:44:14 -0700, bobrics wrote:

> the reason I want to do this is because I have a logical statement
> which returns NxM logical matrix B  flagging the values from another
> numeric matrix A which I need to do operations on.
>
> I want to update values of A at indeces found from B with new values.
>
> I know that A(B), where B is numeric, will do the job. That's why I
> want to find indeces of 1's in my logical B array.

Why don't you just use the logical matrix directly?  You can.

If you really want the numeric indices, type

help find

Dan

Report this thread to moderator Post Follow-up to this message
Old Post
Dan Hensley
06-01-05 02:01 AM


Re: Find indeces of 1's in logical array
bobrics wrote:
>
>
> the reason I want to do this is because I have a logical statement
> which returns NxM logical matrix B flagging the values from
> another
> numeric matrix A which I need to do operations on.
>
> I want to update values of A at indeces found from B with new
> values.
>
> I know that A(B), where B is numeric, will do the job. That's why I
> want to find indeces of 1's in my logical B array.
>
>

One among many. Probably fast. Surely a bit cryptic. Does it help
you?
 
B =
1 0 1
0 0 1
0 1 0 
A =
117 1 117
3 5 117
4 117 2 

/ per

Report this thread to moderator Post Follow-up to this message
Old Post
per isakson
06-01-05 02:01 AM


Re: Find indeces of 1's in logical array
That helped a lot..
I was doing that before.. but I guess made some mistake...
instead of putting the values at indeces, it just replaced the whole
matrix,,, even though I was using logical vector.

The end result is more important! Thank you guys!


Report this thread to moderator Post Follow-up to this message
Old Post
bobrics
06-01-05 02:01 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Matlab archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:40 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.