# calculate new table from values of old table and find fit model curve

I'm new to mathematica and I'm struggling to figure this out.

I have a file with 6 space separated numerical data columns. Column 3 and 4 are the x and y values of the real data, column 5 and 6 are the correct values it should have. The errors in the real data have a radial dependency, I want to calculate radii for real and correct data, calculate the relative deviation depending on the radius and find the best fitting model curve for the deviation.

I got the data read from the file with

data = ReadList["/path/to/data_file.txt", {Number, Number, Number, Number, Number, Number}]


To my understanding the Fit or FindFormula functions need the data in {{x1, f1}, {x2, f2}, ...} format. However I'm failing to calculate a new table from data that contains calculated radius and deviation pairs; I want to do something like

loop over all rows of "data" with row index i:
deviation[i] = { Sqrt[ data[i][5]^2 + data[i][6]^2 ], Sqrt[ data[i][3]^2 + data[i][4]^2 ] / Sqrt[ data[i][5]^2 + data[i][6]^2 ] }

• Welcome! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – user9660 Aug 21 '16 at 19:37
• And when you do Table[deviation[i]={Sqrt[....[6]^2]},{i,Length[data]}? – Feyre Aug 21 '16 at 21:15
• @Feyre no, because {i, Length[data]} will give me the row index of data as variable, however I need the radius as variable – Matthias Aug 22 '16 at 11:21
• This uses i is variable, and increases i by +1 up to Length[data]. Note that [[i]] is the ith element, so not [i] – Feyre Aug 22 '16 at 11:46
• your main issue seems to be basic syntax, mathematica uses double brackets for list items, so you should have data[[i,3]], not data[i][3], then use Table as suggested. – george2079 Aug 22 '16 at 21:58