many thanks, thats perfect

Jon

On Sunday, January 26, 2014 1:03:38 PM UTC+1, Johan Sigfrids wrote:
>
> If you create a type  with fields b and other and put it in a vector a it 
> should work:
>
> # Create the type
> type Bother
>     b::Vector
>     other::Vector
> end
> # Initialize the array
> a = [ Bother(zeros(Int64,10), zeros(20)) for x in 1:2 ]
> # Then your assignments work (after fixing the parenthesis)
> a[1].b[1:10] = 10
> a[1].other[1:20] = 9.2
> a[2].b[1:10] = 5
> a[2].other[1:20] = 1.22
>
>
>
> On Sunday, January 26, 2014 12:47:15 PM UTC+2, Jon Norberg wrote:
>>
>> Hi
>>
>> I am trying to create nested structs like in matlab. I understand types 
>> are the equivalent. I want to be able to create something like 
>>
>> a[1].b[1:10]=10
>> a[1].other[1:20)=9.2
>> a[2].b[1:10]=5
>> a[2].other[1:20)=1.22
>>
>> Also, how would one list all fields like
>>
>> fields(a)
>>
>> "b"
>> "other"
>>
>> I have been trying to get this to work with types but if anyone can help 
>> me I'd be much grateful.
>>
>>

Reply via email to