Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Compare Structure Entries
Date: Mon, 31 Dec 2012 08:18:11 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 13
Message-ID: <kbrho3$b08$1@newscl01ah.mathworks.com>
References: <kbr33c$nvs$1@newscl01ah.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1356941891 11272 172.30.248.47 (31 Dec 2012 08:18:11 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 31 Dec 2012 08:18:11 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:785671

"Zeph Davies" wrote in message <kbr33c$nvs$1@newscl01ah.mathworks.com>...

> I know the solution:
> for i = 1:length(A)
> isequal(A(i),B)
> end
> But this uses a loop. Is it possible without a loop?

arrayfun(@(x) isequal(x,B), A) 

But intrinsically this solution is not better than the for-loop.

Bruno