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: how to assign multiple structure elements at once
Replies: 5   Last Post: Nov 17, 2012 10:01 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Matt J

Posts: 4,997
Registered: 11/28/09
Re: how to assign multiple structure elements at once
Posted: Nov 16, 2012 7:54 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Fatih" wrote in message <k859fd$1fr$>...
> Hi Mat,
> Thanks for your post, however that does not help me much and the reason is the structure organization should not be like the one you gave with your post.
> Say I have 10 buses (a) operating daily in a route and I am sampling every hour the number of passengers (s) riding each of those buses. Some of those buses can be broken at any sampling time, and I am only recording that data for good buses. So if that bus does not work any more the number of passengers field will not be updated anymore.
> So by looking at this example a.s(:,2) = [1;2;3] does not work. Maybe I should change the organization or just use a for loop.
> I was thinking there can be a trick like deal function that fits here nicely.


It sounds preferable to use a 10xN matrix where N is the number of sampling times to record the data and put it in NaN at hours where a particular bus is not working. Not only is this much easier to index/access, but notice also that that would ensure that your samples are always synchronized if a bus breaks for some period of samples and then starts working again. That's much harder to do if you simply don't record the activity of broken buses.

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.