Re: Problems with scalar structures [message #11799] |
Tue, 26 May 1998 00:00 |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Brian Jackel <jackel@danlon.physics.uwo.ca> writes:
>
> Can anyone suggest a (simple, elegant) way to deal with
> the generic command
>
> test.x= test.x * a
>
> where "test.x" and "a" are arrays of length N, and N is
> sometimes equal to 1?
I use the following, and it seems to work fine:
test(*).x = test(*).x * a
It works under both IDL 4 and 5. By the way, I think even "scalar"
structures are actually vectors of length one, so this notation should
always work.
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@astrog.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: Problems with scalar structures [message #11806 is a reply to message #11799] |
Tue, 26 May 1998 00:00  |
Peter Mason
Messages: 145 Registered: June 1996
|
Senior Member |
|
|
On Mon, 25 May 1998, Brian Jackel wrote:
> Here's a little problem that I'd appreciate some input
> on. Consider a simple structure, and an array of those
> structures:
>
> test= {MYSTRUC, name:'mystruct', x:0.0}
> test2= REPLICATE({MYSTRUC},2)
>
> Then try the following two operations, and watch the
> second one fail (at least for version 5.0.2 under IRIX).
>
> test2.x= test2.x * [1.0, 2.0]
> test.x= test.x * [1.0]
>
<...>
> Can anyone suggest a (simple, elegant) way to deal with
> the generic command
> test.x= test.x * a
The best way would be to upgrade to IDL 5.1, which copes with this OK (on WinNT
at least).
But perhaps like me you have at least some platforms "stuck on 5.0x" on account
of ENVI! In this case, try:
test.x(0)= test.x * a
This appears to work, because you can zero-subscript just about anything in IDL.
Peter Mason
|
|
|