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:
Using "find" in structures - same as post with subject "Seth"

Subject: Using "find" in structures - same as post with subject "Seth"

From: Seth

Date: 29 Oct, 2008 00:20:12

Message: 1 of 3

Hi all,
Sorry for the double post. I ended up giving my last post my name as a subject and wanted to make sure that it was clear what was going on. --Seth
>>>>Original Post>>>>

I am trying to search a structure and extract the array numbers that contain data that match certain criteria. I am trying to search with the "find" function. The structure arrays are information of a finite element mesh and look like

Elements.Type = integer describing the element type (ie 1 = tetrahedron, 2 = cube, etc)

Elements.Nodes = integers describing the nodes that make up the element. the node x,y,z coordinates are in a separate structure.

Elements.E = double describing the modulus of elasticity

Elements.Nu = double describing the Poisson's ratio

Elements.bounds = doubles describing the bounding box of the element in question and is arranges like:

Elements(i).bounds =
[x_min,y_min,z_min;
x_max,y_max,z_max] for element i

I have an x-y plane (I have the z-coordinate) and I want to find the elements that intersect the plane in question. The method is to find elements where z_min <= z and z_max >= z. My initial try at this looked like

elem_intersect = find(Elements.bounds(1,3) < z_coordinate & Elements.bounds(2,3) > z_coordinate);

What I was hoping to get was a list of the array numbers for the arrays in "Elements" that match the above criteria. So I could then do the rest of my analysis by stepping through
        elem_intersect,
opening
        Elements( elem_intersect(i) ).E
for modification.

I was hoping not to add the steps of converting the Elements.bounds field to a cell, then cell to matrix.

Is there a way to use the find function on structures like this?

Thanks for your help,
Seth

Subject: Using "find" in structures - same as post with subject "Seth"

From: Bruno Luong

Date: 29 Oct, 2008 07:04:02

Message: 2 of 3

z = something;
criteria=@(e) (e.bounds(1,3)<=z & e.bounds(2,3)>=z);
iitersect = find(arrayfun(criteria, Elements));

Bruno

Subject: Using "find" in structures - same as post with subject "Seth"

From: Seth

Date: 6 Nov, 2008 19:00:20

Message: 3 of 3

Thank you Bruno,
This worked like a charm!

Seth

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <ge91t1$o72$1@fred.mathworks.com>...
> z = something;
> criteria=@(e) (e.bounds(1,3)<=z & e.bounds(2,3)>=z);
> iitersect = find(arrayfun(criteria, Elements));
>
> Bruno

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