Skip to main content
added 95 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
ClearAll[f]
f = Transpose @ Delete[Position[#[[5]], 0]] @ Transpose @ # &;

Example:

SeedRandom[1234]
table = RandomInteger[5, {9, 10}];
MatrixForm[table]
MatrixForm[MapAt[Style[#, Blue] &, #, {5, All}] /. 
    Style[0, _] :> Style[0, Red, Bold]] & @ table

enter image description hereenter image description here

table2 = f@table;f @ table;
MatrixForm[table2]

enter image description here

Also

ClearAll[f2]
f2 = #[[All, Complement[Range@Length@#, Flatten@Position[#, 0]] &@#[[5]]]] &;

f2 @ table == f @ table
 True
ClearAll[f]
f = Transpose @ Delete[Position[#[[5]], 0]] @ Transpose @ # &;

Example:

SeedRandom[1234]
table = RandomInteger[5, {9, 10}];
MatrixForm[table]

enter image description here

table2 = f@table;
MatrixForm[table2]

enter image description here

Also

ClearAll[f2]
f2 = #[[All, Complement[Range@Length@#, Flatten@Position[#, 0]] &@#[[5]]]] &;

f2 @ table == f @ table
 True
ClearAll[f]
f = Transpose @ Delete[Position[#[[5]], 0]] @ Transpose @ # &;

Example:

SeedRandom[1234]
table = RandomInteger[5, {9, 10}];

MatrixForm[MapAt[Style[#, Blue] &, #, {5, All}] /. 
    Style[0, _] :> Style[0, Red, Bold]] & @ table

enter image description here

table2 = f @ table;
MatrixForm[table2]

enter image description here

Also

ClearAll[f2]
f2 = #[[All, Complement[Range@Length@#, Flatten@Position[#, 0]] &@#[[5]]]] &;

f2 @ table == f @ table
 True
added 155 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
ClearAll[f]
f = Transpose @ Delete[Position[#[[5]], 0]] @ Transpose @ # &;

Example:

SeedRandom[1234]
table = RandomInteger[5, {9, 10}];
MatrixForm[table]

enter image description here

table2 = f@table;
MatrixForm[table2]

enter image description here

Also

ClearAll[f2]
f2 = #[[All, Complement[Range@Length@#, Flatten@Position[#, 0]] &@#[[5]]]] &;

f2 @ table == f @ table
 True
ClearAll[f]
f = Transpose @ Delete[Position[#[[5]], 0]] @ Transpose @ # &;

Example:

SeedRandom[1234]
table = RandomInteger[5, {9, 10}];
MatrixForm[table]

enter image description here

table2 = f@table;
MatrixForm[table2]

enter image description here

ClearAll[f]
f = Transpose @ Delete[Position[#[[5]], 0]] @ Transpose @ # &;

Example:

SeedRandom[1234]
table = RandomInteger[5, {9, 10}];
MatrixForm[table]

enter image description here

table2 = f@table;
MatrixForm[table2]

enter image description here

Also

ClearAll[f2]
f2 = #[[All, Complement[Range@Length@#, Flatten@Position[#, 0]] &@#[[5]]]] &;

f2 @ table == f @ table
 True
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

ClearAll[f]
f = Transpose @ Delete[Position[#[[5]], 0]] @ Transpose @ # &;

Example:

SeedRandom[1234]
table = RandomInteger[5, {9, 10}];
MatrixForm[table]

enter image description here

table2 = f@table;
MatrixForm[table2]

enter image description here