Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
cell & ismember or intersect

Subject: cell & ismember or intersect

From: biosea Kim

Date: 3 Aug, 2007 13:19:44

Message: 1 of 2

r=cell(10);
r{1,1}=1:5;
r{1,5}=6:10;

In the example abvoe, I would like to know the location of
6, which is the 5th array of cell. I used intersect or
ismember to find the location, but it didn't work. It says
that it should be "string" in order to use "intersect" or
"ismember" in cell array. I am trying to avoid loop and
"string" to perform such functions in huge simulations.

In the same example above, I also would like to find the
first empty cell. Would you help me to do it? I used a loop
"for", but in my huge simulations, I would like to avoid
this loop.

Thanks in advance.

Subject: cell & ismember or intersect

From: French Caro

Date: 3 Aug, 2007 14:09:10

Message: 2 of 2

Hi,
CELLFUN may help :
[i,j]=find(cellfun(@(x)ismember(6,x),r))

"biosea Kim" <sinae76@hotmail.com> wrote in message
<f8va1g$c5m$1@fred.mathworks.com>...
> r=cell(10);
> r{1,1}=1:5;
> r{1,5}=6:10;
>
> In the example abvoe, I would like to know the location of
> 6, which is the 5th array of cell. I used intersect or
> ismember to find the location, but it didn't work. It says
> that it should be "string" in order to use "intersect" or
> "ismember" in cell array. I am trying to avoid loop and
> "string" to perform such functions in huge simulations.
>
> In the same example above, I also would like to find the
> first empty cell. Would you help me to do it? I used a loop
> "for", but in my huge simulations, I would like to avoid
> this loop.
>
> Thanks in advance.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us