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:
find function for structure of arrays?

Subject: find function for structure of arrays?

From: Lin

Date: 18 Mar, 2009 07:43:04

Message: 1 of 4

Hi all.

say

imag_val = [0 1; 1 0];
gek{1}= {[0;1],[1;0]};
gek{2}= {};

find_content_gek = @(x) isequal(x, (imag_val(:,1)));
check_content= find(cellfun(find_content_gek, gek));
[cr,cc] = ind2sub(size(gek),check_content);

If the above is applied to multi-dimensional array, it could work well, but when i extend to structure of arrays, i cannot obtain the desired results. Why is this so?

Subject: find function for structure of arrays?

From: Lin

Date: 19 Mar, 2009 02:30:04

Message: 2 of 4

"Lin " <shenqlv@yahoo.com> wrote in message <gpq8m8$824$1@fred.mathworks.com>...
> Hi all.
>
> say
>
> imag_val = [0 1; 1 0];
> gek{1}= {[0;1],[1;0]};
> gek{2}= {};
>
> find_content_gek = @(x) isequal(x, (imag_val(:,1)));
> check_content= find(cellfun(find_content_gek, gek));
> [cr,cc] = ind2sub(size(gek),check_content);
>
> If the above is applied to multi-dimensional array, it could work well, but when i extend to structure of arrays, i cannot obtain the desired results. Why is this so?

I dont see any doc related to my problem. Does anyone has any ideas? Thanks for helping.

Subject: find function for structure of arrays?

From: Jos

Date: 19 Mar, 2009 06:30:08

Message: 3 of 4

"Lin " <shenqlv@yahoo.com> wrote in message <gpq8m8$824$1@fred.mathworks.com>...
> Hi all.
>
> say
>
> imag_val = [0 1; 1 0];
> gek{1}= {[0;1],[1;0]};
> gek{2}= {};
>
> find_content_gek = @(x) isequal(x, (imag_val(:,1)));
> check_content= find(cellfun(find_content_gek, gek));
> [cr,cc] = ind2sub(size(gek),check_content);
>
> If the above is applied to multi-dimensional array, it could work well, but when i extend to structure of arrays, i cannot obtain the desired results. Why is this so?

I do not understand what you mean by "structure of arrays". Perhaps you can give us a small example of the input and expected output?

Jos

Subject: find function for structure of arrays?

From: Lin

Date: 19 Mar, 2009 08:38:01

Message: 4 of 4

"Jos " <#10584@fileexchange.com> wrote in message <gpsopg$k27$1@fred.mathworks.com>...
> "Lin " <shenqlv@yahoo.com> wrote in message <gpq8m8$824$1@fred.mathworks.com>...
 
> I do not understand what you mean by "structure of arrays". Perhaps you can give us a small example of the input and expected output?
>
> Jos

%Suppose this is my input:
gek(1).f = {[1;1],[1;0]}
gek(2).f = {[1;0],[2;3]}

%expected results:
index where [1;0] is stored.

i need to search through gek to see if [1;0] exists. If yes, store the index(something similar to the find function) and display the results. I am not sure this is workable. please advise should you have a better solution. Thank you.

Tags for this Thread

No tags are associated with 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