Le samedi 25 juillet 2015 à 06:55 -0700, Joe Tusek a écrit :
> Hi, I am trying to convert some Matlab code where structured data 
> variables were used that were composed of complex and real data which 
> is passed to a function. The original Matlab call was [poles, L2] = 
> PSO("FLBF",lb,ub,poles,data)  and data is of the form data.Y and
>  data.w, where Y is a complex number and w the frequency.
> 
> In Julia I have defined the following structure
> 
> type Data_array
>   Y::Float64
>   w::Float64
> end
> 
> but am not clear on how to get Y to be a complex Float64? I tried 
> Complex(Float64), and Array(Float64,1041) versions as well as 
> combinations of im but these were all rejected.
> 
> If I comment out the non compliant lines of code so it will run, I 
> see that Y is of size (1041,1)  and w is of size (1, 1041). Trying to 
> form the data variable using    
> data = Data_array(Y, w) 
> suffers a conversion error.
> 
> Can someone advise on how to make the needed structured variable?
Complex(Float64) tries to build a complex holding the *value* Float64,
which doesn't make sense. To specify a type parameter, use
Complex{Float64}. There's also the alias Complex128, if you prefer.

Regards

Reply via email to