Create list of {x,f(x)} pairs

237 Views Asked by At

How can I do this in Mathematica:

r=Range[0,20,0.13];
fr = HeavisideTheta[r];
data = somecoolfunctionsinmathematica[r,fr]

So that data now is in the form useful to Fit: {{r_1,fr_1},{r_2,fr_2},...}

Thanks!

2

There are 2 best solutions below

0
On BEST ANSWER

This is the correct way to use Table if you prefer it to Map:

Table[{i, HeavisideTheta[10 - i]}, {i, 0, 20, 0.013}]
4
On

I've found it, albeit syntactically a bit... involved (but I've seen a lot worse):

data = Table[{r[i], HeavisideTheta[10-r[i]]}, {r[i], Range[0, 20, 0.013]}]