Try something like this:
adjCloseMuVec = Vector{Float32}(nFullYears)
or
adjCloseMuVec = zeros(Float32, nFullYears)
This will init a vector of the proper size. I think zeros is slightly
faster, but someone can correct me if that is not the case.
Chris
On Thursday, January 28, 2016 at 1:26:09 AM UTC-5, Michael Landis wrote:
>
> I am trying to compute some historical means and volatilities with Julia,
> but I've been having some difficulty getting the declarations and/or
> assignments right...
>
> When I try a declaration, like either of these:
> adjCloseMuVec::Vector{Float32}; # or...
> adjCloseMuVec::Vector{Float32,nFullYears};
> I get: UndefVarError: adjCloseMuVec not defined
>
> When I try:
> adjCloseMuVec = Vector{Float32}; # and later try:
> reshape(adjCloseMuVec,nFullYears);
> I get: MethodError: `reshape` has no method matching
> reshape(::Type{Array{Float32,1}}, ::Int32)
>
> When I try:
> adjCloseMuVec = Vector{Float32,nFullYears};
> I get: too many parameters for type typealias
>
> So, the only acceptable path would seem to be:
> adjCloseMuVec = Vector{Float32};
> but when I later try:
> adjCloseMuVec[curYr] = Float32(adjCloseMu); # or...
> setindex!(adjCloseMuVec, Float32(adjCloseMu), curYr);
> I get: MethodError: `setIndex!` has no method matching
> setindex!(::Type{Array{Float32,1}}, ::Float32, ::Int64)
>
> So, I'm mystified as to the correct syntax. Any suggestions on an
> acceptable way to declare a Vector of Int32 and load values into it?
>