Skip to main content
added 14 characters in body
Source Link
Basheer Algohi
  • 20k
  • 1
  • 32
  • 78
n = Length@x;Dimensions[x];
ReplacePart[x, {i_, j_} /; 2;2 <= i <= nn[[1]] - 1 && 2 <= j <= nn[[2]] - 1 :>0]> 0]

another way:

MapAt[Times[0, #]MapAt[0 &, x, {2 ;; -2, 2 ;; -2}]
n = Length@x;
ReplacePart[x, {i_, j_} /; 2 <= i <= n - 1 && 2 <= j <= n - 1 :>0] 

another way:

MapAt[Times[0, #] &, x, {2 ;; -2, 2 ;; -2}]
n = Dimensions[x];
ReplacePart[x, {i_, j_} /;2 <= i <= n[[1]] - 1 && 2 <= j <= n[[2]] - 1 :> 0]

another way:

MapAt[0 &, x, {2 ;; -2, 2 ;; -2}]
Source Link
Basheer Algohi
  • 20k
  • 1
  • 32
  • 78

n = Length@x;
ReplacePart[x, {i_, j_} /; 2 <= i <= n - 1 && 2 <= j <= n - 1 :>0] 

another way:

MapAt[Times[0, #] &, x, {2 ;; -2, 2 ;; -2}]