Well, you just made the type D, so you can make Array{D,n} or anything else 
like that. The Base types are not special in Julia, anywhere you can use a 
type, you can use your own.

You can create an empty form of your type via dinstance = D(). You can then 
add to it by setting dinstance.data = someMatrix; dinstance.header = "hi!". 
In fact, you can make a whole array of empty D's by Darr = [D() for i in 
1:N] and then set the fields in a loop by Darr[i].data = someMatrix. You 
might want to read the documentation on type for more details.

If you need the fields to be mutable, you can make one of the fields in the 
type be a dictionary and use that, or you can use a cell array (I think 
these may be deprecated?)


On Friday, July 15, 2016 at 6:14:26 PM UTC-7, J Luis wrote:
>
> Hi,
>
> I need to mimic what in Matlab is called a struct matrix. e.g.
>
> >> D=struct('data',{rand(2,2);rand(2,2)},'text',{'aa';'bb'})
>
> D = 
>
> 2x1 struct array with fields:
>
>     data
>     text
>
>
> in MEX I would use (and actually that's what I do in the C MEX code that 
> I'm trying to port)
>
> mxCreateStructMatrix()
>
> For one single of this it's easy
>
> type D
>        data::Array{Float64,2}
>        header::ASCIIString
>        end
>
> but how do I create an array of D's?
> And probably worst, I need to fill them with the data that comes from a 
> ccall(). So not only I do not know to create the array as I have no idea 
> either on how fill it since one cannot create empty types and fill them in 
> loops.
>
> Thanks
>

Reply via email to