Initializing structure arrays
- From: "Gregory Jones" <Gregory.Jones@xxxxxxxxxxxxx>
- Date: Thu, 26 Apr 2007 11:19:20 -0400
Is there an effective way to allocate memory and initialize a
structure array? For example, let's say we have a 1x1000000 myArray
structure array with fields
..name
..age
where .name is a string of unknown length, but length probably not to
exceed 30, and .age is an integer, say a uint8
we have tried the technique of repmat, i.e.
myArray.name='John Chrysanthemum Doe';
myArray.age=18;
myArray=repmat(myArray,1,1000000);
however, due to matlab's delayed copy, it does not actually allocate
memory for this. I know this for a fact because I was dealing with
1 gig variables and I could repmat them with impunity.
if instead we start with
myArray(1,1000000).name='John Chrysanthemum Doe';
myArray(1,1000000).age=18;
then certainly some memory will be allocated to the other ~million
entries, but they are set to be empty matrices. is the right amount
of space (~30 characters) reserved for the .name field?
is there any other technique? commands like ones( ),
zeros( ) only take elementary classnames?
Gregory Jones
.
- Follow-Ups:
- Re: Initializing structure arrays
- From: us
- Re: Initializing structure arrays
- Prev by Date: transfer function question
- Next by Date: Re: Real-Time Movie in Matlab
- Previous by thread: transfer function question
- Next by thread: Re: Initializing structure arrays
- Index(es):
Relevant Pages
|
Loading