Database

[{matrix_id:1,row_id:0,values:[1,2,3]},{matrix_id:1,row_id:1,values:[4,5,6]},{matrix_id:2,row_id:0,values:[20,40,60]},{matrix_id:2,row_id:1,values:[80,100,120]}]

Query

db.collection.update({matrix_id:1},[{$set:{values:{$let:{vars:{/** index of the column being updated*/col_idx:1,/** the full replacement column*/new_col:[7890,9876]},in:{$concatArrays:[/** existing values before the replacement*/{$slice:["$values","$$col_idx"]},/** the replacement*/[{$arrayElemAt:["$$new_col","$row_id"]}],/** existing values after the replacement*/{$slice:["$values",{$add:["$$col_idx",1]},{/** can subtract remaining length but* it doesn't affect the result*/$size:"$values"}]}]}}}}}],{multi:true})

Result