Thread Subject: Error using ==> cellfun

Subject: Error using ==> cellfun

From: Xiao

Date: 30 Jan, 2009 08:19:05

Message: 1 of 10

Hi all.

I got the following error when executing my program

%Error using ==> cellfun%
%Input #2 expected to be a cell array, was double instead.%

How can I correct this error?

my program is attached as follows:

Thanks in advance.

network = cat(3, [ 11 12 0;
                             0 0 11;
                             0 0 12;
                             0 0 0;
                             0 0 0 ], [21 22 0;
                                              0 0 21;
                                              0 0 22;
                                              0 0 0;
                                              0 0 0]);
ind = ~cellfun(@isempty,network);
[rx,cx,dx]=find(ind(:,sum(ind)>1));

Subject: Error using ==> cellfun

From: Jos

Date: 30 Jan, 2009 10:50:02

Message: 2 of 10

"Xiao " <viva_paradise@hotmail.com> wrote in message <glud5p$o60$1@fred.mathworks.com>...
> Hi all.
>
> I got the following error when executing my program
>
> %Error using ==> cellfun%
> %Input #2 expected to be a cell array, was double instead.%
>
> How can I correct this error?
>
> my program is attached as follows:
>
> Thanks in advance.
>
> network = cat(3, [ 11 12 0;
> 0 0 11;
> 0 0 12;
> 0 0 0;
> 0 0 0 ], [21 22 0;
> 0 0 21;
> 0 0 22;
> 0 0 0;
> 0 0 0]);
> ind = ~cellfun(@isempty,network);
> [rx,cx,dx]=find(ind(:,sum(ind)>1));

"empty" is not the same as "being zero"

find(network ~= 0)

hth
Jos

Subject: Storing the address

From: Xiao

Date: 30 Jan, 2009 11:49:01

Message: 3 of 10

Suppose i change the network to something as follows:

test = cat(3, { [11] [12] [];
                              [] [] [11];
                              [] [] [12];
                              [] [] [];
                              [] [] [] }, { [21] [22] [];
                                                         [] [] [21];
                                                         [] [] [22];
                                                         [] [] [];
                                                         [] [] [] } );
ind = ~cellfun(@isempty,network);
[rx,cx,dx]=find(ind(:,sum(ind)>1));

The statement that i had wrote earlier can be used in this context.

What i need to obtain is something as follows:
% row/Col/Page
    2/3/1
    3/3/1
    2/3/2
    3/3/2

but, the results does not tally if you run the program. How can I solve the problem?

Thanks for any suggestions.

"Jos " <#10584@fileexchange.com> wrote in message <glum0q$1nr$1@fred.mathworks.com>...
> "Xiao " <viva_paradise@hotmail.com> wrote in message <glud5p$o60$1@fred.mathworks.com>...
> > Hi all.
> >
> > I got the following error when executing my program
> >
> > %Error using ==> cellfun%
> > %Input #2 expected to be a cell array, was double instead.%
> >
> > How can I correct this error?
> >
> > my program is attached as follows:
> >
> > Thanks in advance.
> >
> > network = cat(3, [ 11 12 0;
> > 0 0 11;
> > 0 0 12;
> > 0 0 0;
> > 0 0 0 ], [21 22 0;
> > 0 0 21;
> > 0 0 22;
> > 0 0 0;
> > 0 0 0]);
> > ind = ~cellfun(@isempty,network);
> > [rx,cx,dx]=find(ind(:,sum(ind)>1));
>
> "empty" is not the same as "being zero"
>
> find(network ~= 0)
>
> hth
> Jos

Subject: Storing the address

From: Xiao

Date: 30 Jan, 2009 17:06:02

Message: 4 of 10

Hi all.

I am still stuck with this problem that i have mentioned earlier.

Can someone help me in this?

Thanks in advance.

"Xiao " <viva_paradise@hotmail.com> wrote in message <glupfd$fv2$1@fred.mathworks.com>...
> Suppose i change the network to something as follows:
>
> test = cat(3, { [11] [12] [];
> [] [] [11];
> [] [] [12];
> [] [] [];
> [] [] [] }, { [21] [22] [];
> [] [] [21];
> [] [] [22];
> [] [] [];
> [] [] [] } );
> ind = ~cellfun(@isempty,network);
> [rx,cx,dx]=find(ind(:,sum(ind)>1));
>
> The statement that i had wrote earlier can be used in this context.
>
> What i need to obtain is something as follows:
> % row/Col/Page
> 2/3/1
> 3/3/1
> 2/3/2
> 3/3/2
>
> but, the results does not tally if you run the program. How can I solve the problem?
>
> Thanks for any suggestions.
>
> "Jos " <#10584@fileexchange.com> wrote in message <glum0q$1nr$1@fred.mathworks.com>...
> > "Xiao " <viva_paradise@hotmail.com> wrote in message <glud5p$o60$1@fred.mathworks.com>...
> > > Hi all.
> > >
> > > I got the following error when executing my program
> > >
> > > %Error using ==> cellfun%
> > > %Input #2 expected to be a cell array, was double instead.%
> > >
> > > How can I correct this error?
> > >
> > > my program is attached as follows:
> > >
> > > Thanks in advance.
> > >
> > > network = cat(3, [ 11 12 0;
> > > 0 0 11;
> > > 0 0 12;
> > > 0 0 0;
> > > 0 0 0 ], [21 22 0;
> > > 0 0 21;
> > > 0 0 22;
> > > 0 0 0;
> > > 0 0 0]);
> > > ind = ~cellfun(@isempty,network);
> > > [rx,cx,dx]=find(ind(:,sum(ind)>1));
> >
> > "empty" is not the same as "being zero"
> >
> > find(network ~= 0)
> >
> > hth
> > Jos

Subject: Storing the address

From: us

Date: 30 Jan, 2009 18:00:17

Message: 5 of 10

"Xiao"
> I am still stuck with this problem that i have mentioned earlier...

a hint:

simply use the solution, which was shown to you 2 days ago at

http://groups.google.com/group/comp.soft-sys.matlab/msg/e5f92e263af17f3c

in a loop...

us

Subject: Storing the address

From: Xiao

Date: 31 Jan, 2009 03:52:01

Message: 6 of 10

Ya.

I tried the solution.

ix=sum(~cellfun(@isempty,test))<=1;
     test(:,ix)={[]};
     [rx,cx,dx]=find(~cellfun(@isempty,test));

but it does not display the correct result. The value of dx is a logical value, not the page number of the multi-dimensional array. Only value of the rx and cx is correct.

how can I amend the statement so that it will store the correct address of the multi-dimensional array?

Thanks.

"us " <us@neurol.unizh.ch> wrote in message <glvf7h$m2k$1@fred.mathworks.com>...
> "Xiao"
> > I am still stuck with this problem that i have mentioned earlier...
>
> a hint:
>
> simply use the solution, which was shown to you 2 days ago at
>
> http://groups.google.com/group/comp.soft-sys.matlab/msg/e5f92e263af17f3c
>
> in a loop...
>
> us

Subject: Storing the address

From: Matt Fig

Date: 31 Jan, 2009 07:03:10

Message: 7 of 10

Seems like you should use a loop, but if you insist on a "vectorized" approach, here is one.



test = cat(3, { [11] [12] [];
                              [] [] [11];
                              [] [] [12];
                              [] [] [];
                              [] [] [] }, { [21] [22] [];
                                                         [] [] [21];
                                                         [] [] [22];
                                                         [] [] [];
                                                         [] [] [] } )

idx2 = repmat(sum(~cellfun(@isempty,test))>1,[size(test,1),1,1]);
test(~idx2) = {[]};
idx4 = ~cellfun(@isempty,test);
[rx,cx,px] = ind2sub(size(idx4),find(idx4));

rx_cx_px = [rx,cx,px]

rx_cx_px =

     2 3 1
     3 3 1
     2 3 2
     3 3 2




NZL0jRq_P[D`8YLZZj[jLdYPMjTSLXVqPZP_WWNTjj%ZXLL+SxL`jS_ZajM

Subject: Storing the address

From: Matt Fig

Date: 31 Jan, 2009 15:32:01

Message: 8 of 10

Now that I am a little more awake, I see we can get rid of the second cellfun call:

idx1 = ~cellfun(@isempty,test);
idx2 = repmat(sum(idx1)>1,[size(test,1),1,1]);
idx3 = idx2 & idx1;
[rx,cx,px] = ind2sub(size(idx3),find(idx3));

rx_cx_px = [rx,cx,px] % The results.

rx_cx_px =

     2 3 1
     3 3 1
     2 3 2
     3 3 2




\sZll\ls-aY]fNZN'XY\lNFzN[N:lVUblacPlNPOVO[2\TRN]UR\\UbRaRl

Subject: Storing the address

From: ImageAnalyst

Date: 31 Jan, 2009 17:15:15

Message: 9 of 10

On Jan 31, 10:32=A0am, "Matt Fig" <spama...@yahoo.com> wrote:

> \sZll\ls-aY]fNZN'XY\lNFzN[N:lVUblacPlNPOVO[2\TRN]UR\\UbRaRl
Matt Fig:
What are the strings of random characters at the end of your messages
supposed to be?
Just wondering.......

Subject: Storing the address

From: Matt Fig

Date: 31 Jan, 2009 23:25:03

Message: 10 of 10

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <c84ddf31-c59f-4f4c-
> What are the strings of random characters at the end of your messages
> supposed to be?
> Just wondering.......


It is a simple, silly, alphabetic substitution-transposition enciphered message (always the same), open to anyone, with a Matlab 'twist.'




adbt{jXttVtaVtt5dZ/`tkN{cZ:jdteZVd^cd^VX]ZiiVVWiWBde#]\b]nV

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
reference us 30 Jan, 2009 13:05:21
cssm us 30 Jan, 2009 13:05:21
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com