MethodError: no method matching

Hi

I have tested a matrix operation in Julia:
i.e.

test=zeros(Float64,6,4,4)

test[6,1:4,2:4] = 1.0

ERROR: MethodError: no method matching setindex_shape_check(::Float64, ::Int64, ::Int64, ::Int64)

The solution in Matlab:


val(:,:,1) =

     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0


val(:,:,2) =

     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0
     1     1     1     1


val(:,:,3) =

     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0
     1     1     1     1


val(:,:,4) =

     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0
     1     1     1     1

You need .=, not just =. For more info, see: Multi-dimensional Arrays · The Julia Language

2 Likes

very nice! thank you!