Andrew Smith
Andrew Smith

Reputation: 13

Mathematica: Getting the minimum value in different columns for each row

I have imported data from a *.dat-file in the following form

(Date, Time, x-value, y-value, z-value, vector sum, x-Frequency, y-Frequency,z-Frequency):

18.02.2016 00:00:00 0.049896    0.013689    0.072710    0.086983    11  84  52
18.02.2016 00:01:00 0.048167    0.012106    0.061351    0.077970    149 102 52
18.02.2016 00:02:00 0.048765    0.012528    0.065641    0.081315    149 83  149
18.02.2016 00:03:00 0.048251    0.011859    0.060764    0.076809    149 7   149
18.02.2016 00:04:00 0.048007    0.012076    0.059913    0.076749    149 17  149
18.02.2016 00:05:00 0.048355    0.012759    0.067133    0.083064    149 149 149
18.02.2016 00:06:00 0.048973    0.013583    0.061963    0.079212    149 149 149
18.02.2016 00:07:00 0.057665    0.021322    0.105728    0.113308    9   149 149
18.02.2016 00:08:00 0.050364    0.013635    0.069397    0.084130    149 149 149
18.02.2016 00:09:00 0.048477    0.013015    0.061372    0.078093    149 9   9

Now I would like to get the minimum value of the columns x-,y-,z-Frequency for each row and store it as a single column. How would you do that?

Upvotes: 1

Views: 402

Answers (1)

m0nhawk
m0nhawk

Reputation: 24168

Start by finding the minimum of each column for each row:

minFreq = Min /@ data[[All, -3 ;; -1]]
(* {11, 52, 83, 7, 17, 149, 149, 9, 149, 9} *)

And then insert the column into data (for example):

Transpose@Insert[Transpose@data, minFreq, -1] // MatrixForm

Upvotes: 1

Related Questions