Can you give us the PSO function that you're trying to call? It's unclear
what you really need:
# here each object just holds a pair of values
type DB
Y::Complex128
w::Float64
end
# and fill in the structure like:
data = Array(DB, 100) # creates Array{DB,1} with space for 100 DB
elements, but no actual data yet
for i in 1:100
data[i] = DB(mycomplexnum, myfloatnum)
end
# or you could do
data = DB[] # creates empty Array{DB,1}
for i in 1:100
push!(data, DB(mycomplexnum, myfloatnum)
end
Or if you want 1 structure to just hold pointers to an Array{Complex128,1}
and an Array{Float64,1}, then use something like Kaj's answer.
Either way, I think we need to see the function you want to call to help
further.
On Sun, Jul 26, 2015 at 5:21 AM, Kaj Wiik <[email protected]> wrote:
> One way would be
>
> a = DB([],[])
> a.Y=rand(Complex{Float64},100)
> a.W=rand(Float64,100)
>
> or just
>
> b = DB(rand(Complex{Float64},100),rand(100))
>
> Kaj
>
>
>
>
> On Sunday, July 26, 2015 at 8:44:14 AM UTC+3, Joe Tusek wrote:
>>
>> Tom thanks, sorry to be asking such basic questions, I have access to the
>> reference manual but can't get enough out of it to see what the correct
>> syntax is. I settled on trying just some simple code as below that
>> was making a structure DB and then trying to make an array of 100 elements
>> with that structure
>>
>> type DB
>> Y::Vector{Complex128}
>> W::Vector{Float64}
>> end
>>
>> y = Array(Complex128,100)
>> w = Array(Float64,100)
>>
>> data = Array(DB,100) # making an array of 100 elements of type DB
>>
>> data[10].Y = 2.0+3.0im # this results in an getindex error as there is
>> no method to support the assignment.
>>
>> Can someone advise the correct syntax for making data an array with 100
>> elements of type DB and filling it with vectors instead of iterating
>> through the assignment of the elements?
>>
>>
>>>>