Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Creating Booleans from Vectors
Replies: 5   Last Post: Sep 17, 2013 11:23 PM

 Messages: [ Previous | Next ]
 Michael Posts: 12 Registered: 6/18/12
Re: Creating Booleans from Vectors
Posted: Sep 17, 2013 11:21 PM

"Roger Stafford" wrote in message <l1aocj\$n4b\$1@newscl01ah.mathworks.com>...
> "Michael " <mabowles@syr.edu> wrote in message <l1aehk\$d3o\$1@newscl01ah.mathworks.com>...
> > x = [1 3 8 10 11];
> > y = [2 6 9 15];
> > xy_ordered = [1 2 3 6 8 9 10 11 15];
> >
> > cX = [1 0 1 0 1 0 1 1 0]
> > cY = [0 1 0 1 0 1 0 0 1]; %by definition the is ~cX..

> - - - - - - - - - -
> cX = ismember(xy_ordered,x);
> cY = ismember(xy_ordered,y);
>
> The vectors cX and cY are logical vectors which contain true's and false's. To transform them to 1's and 0's, apply "double" to them. Note that if a number lies in both x and y, there will be a 1 (true) in both cX and cY in the same position. It is not necessary that x, y, or xy_ordered be ordered for this code to operate.
>
> Roger Stafford

Thanks a bunch Roger... I used this function recently (and I could NOT for the life of me recall it not to mention its usage). I really appreciate your help. ALthough, I must've fudged something as I don't see where I can flag this as correct.. can you advise? I mean I've been on the forums before (i'm not totally dim) Typically the answers provided (by good folks liek you) are indented.. This is not (for the current screen I'm on).

Again thanks!

Date Subject Author
9/17/13 Michael
9/17/13 dpb
9/17/13 Roger Stafford
9/17/13 dpb
9/17/13 Michael
9/17/13 Michael