From: Steven_Lord on


"guyz Smarty" <guyz.smarty(a)gmail.com> wrote in message
news:i2f5cd$ajl$1(a)fred.mathworks.com...
> Hi all,
>
> I am new to the MATLAB programming and am trying to learn now. I am stuck
> with a problem ( seems bigger for me, but may not be the same for you
> ;) ).
> Suppose A = [2 3 4] .... A vector
>
> and B = [2 1 2
> 3 4 2
> 3 5 4] ..... A Matrix
>
> now I want to check which elements of B are equal to each element of A
> individually, i.e., I want matrices like below:

*snip*

Why? What's your end goal in creating these matrices?

Are you looking for one final logical array whose elements are 0 if the
corresponding element of B is not present in A and 1 if it is? If so, look
at ISMEMBER.

> But I don't want to do it, three times manually. Also I don't want to do
> it with FOR loops (someone told me if I use FOR loops in MATLAB, then I am
> abusing it)

That _MAY_ have been true previously. If used well, FOR loops are a useful
tool.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com