There are a few neat ways to make it work nicely. One is to access the 
value. That is, 
v[2,1]=x[]

Another is to assign as a matrix:
v[2:2,1]=x

Automatic conversion between single-value arrays and numbers could be 
problematic, if care isn't taken. For example, what happens if v is an 
Array of type Any? Does it store the value, or does it store the array 
holding the value? Note that it matters when it comes time to modify the 
entry.

On Sunday, 1 November 2015 02:33:05 UTC+10, Xiaowei Song wrote:
>
> v=zeros(2,3)
> x=rand(1,1)
> v[2,1]=x
> # `convert` has no method matching convert(::Type{Float64}, 
> ::Array{Float64, 2})
>
> #work around
> function returnNum(x)
>   return x[1]
> end
> v[2,2]=returnNum(v)
>
> Has anyone encountered this situation and want a change?
> Is there any other better work around?
> Or should Julia add the automatic conversion from 1x1 matrix to a num?
>
> Thanks,
>

Reply via email to