MethodError: no method matching

package
#1

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
0 Likes

#2

You need .=, not just =. For more info, see: https://docs.julialang.org/en/v1/manual/arrays/#Assignment-1

2 Likes

#3

very nice! thank you!

0 Likes