Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using 'size' on a stuct

0 views
Skip to first unread message

James Franklin

unread,
Feb 9, 2010, 6:11:04 PM2/9/10
to
Hi

I have a character array called filename containing 'n040210'.

I have a structure S containing a field called 'n040210'

if i use...

SIZE ( S . n040210 {1} )

ans=

366 5

which is what i want.

but if i use...

SIZE ( S . filename {1} )
??? Reference to non-existent field 'filename'.

I need to use contents of filename as this procedure is part of a loop. what am I doing wrong?

many thanks

James

James Tursa

unread,
Feb 9, 2010, 6:33:04 PM2/9/10
to
"James Franklin" <nos...@hotmail.com> wrote in message <hksq28$dgs$1...@fred.mathworks.com>...

The error message means exactly what it says ... there is no field named "filename". You can use the evil eval function to get your desired result:

eval(['size(S.' filename '{1})'])

James Tursa

Walter Roberson

unread,
Feb 9, 2010, 6:29:56 PM2/9/10
to
James Franklin wrote:

> I have a character array called filename containing 'n040210'.

> SIZE ( S . filename {1} )


> ??? Reference to non-existent field 'filename'.

> I need to use contents of filename as this procedure is part of a loop.

SIZE( S.(filename){1} )

James Franklin

unread,
Feb 17, 2010, 6:20:25 AM2/17/10
to
Hi Walter,

Thanks for your help, the answer was staring me in the face.

thanks again

0 new messages