Home > Archive > Matlab > August 2007 > cell & ismember or intersect
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
cell & ismember or intersect
|
|
| biosea Kim 2007-08-03, 7:23 pm |
| 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.
| |
| French Caro 2007-08-03, 7:23 pm |
| 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.
|
|
|
|
|