1

I have a Table of dimension (49,702). I want to sum over the column values ranging from 1 to 115 and store it in another table of dimension (49,1). How can I go about doing that? TIA

DataPCorrected1 = 
 Table[1 + DataPCorrected[[j, i]], {j, 1, 49}, {i, 1, 115}];

In short, At each row value from 1 to 49, the column values from 1 to 115 gets added and stored. The final result should be a list of dimension {49,1}

Michael E2
  • 235,386
  • 17
  • 334
  • 747
Zihad
  • 31
  • 4
  • 2
    Please show the code you have tried and describe the difficulties you have encountered. – bbgodfrey Jan 10 '22 at 17:41
  • And explain what you mean by "sum over the column values ranging from 5 to 115". – Rohit Namjoshi Jan 10 '22 at 18:11
  • Just did that. Please check. thanks. At each row value from 1 to 49, the column values from 1 to 115 gets added and stored. The final result should be a list of dimension {49,1} – Zihad Jan 10 '22 at 18:13
  • 5
    Welcome to the community. I think this is what your looking for Total[DataPCorrected[[All, 1 ;; 115]], {2}] – Ben Izd Jan 10 '22 at 18:22
  • Thanks, it worked @Ben Izd – Zihad Jan 10 '22 at 18:50
  • Also, perhaps, DataPCorrected[[All, 1 ;; 115]].ConstantArray[1,115]? – user1066 Jan 10 '22 at 20:14
  • Duplicate: https://mathematica.stackexchange.com/questions/22624/convenient-methods-to-sum-select-rows-or-cols-of-a-matrix/22625#22625 -- Related: https://mathematica.stackexchange.com/questions/18540/summing-along-rows-or-columns-of-a-matrix/18543#18543 – Michael E2 Jan 11 '22 at 01:27

0 Answers0