The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Operating on similar elements of different structures
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  

Posts: 48
Registered: 7/30/13
Operating on similar elements of different structures
Posted: Jul 30, 2013 11:16 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


I'm new to using structures and have a question on how to interact with them.

Is there a way to do the same operation on the same parts of different structs?

For example, I've been doing something like this in my scripts:

for k = 1:10
struct(k).arraytwo = struct(k).arrayone * 9.81;
struct(k).arraythree = struct(k).arrayone > 0;
struct(k).arrayfour = cumsum(struct(k).arraythree);

Is there a way to do this without the for loop? like some clever indexing?


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.