0
$\begingroup$

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!

$\endgroup$

2 Answers 2

1
$\begingroup$

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

Table[{i, HeavisideTheta[10 - i]}, {i, 0, 20, 0.013}]
$\endgroup$
0
$\begingroup$

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]}]
$\endgroup$
4
  • $\begingroup$ Map will do it: {#,HeavisideTheta[10-#]}&/@Range[0,20,0.013] $\endgroup$
    – Sasha
    Nov 9, 2011 at 13:16
  • $\begingroup$ Also Transpose[{#, HeavisideTheta[10 - #]}]&[Range[0, 20, 0.013]]... $\endgroup$ Nov 9, 2011 at 13:44
  • $\begingroup$ Funny how the (IMHO) much worse pops up in comments under my answer :) $\endgroup$
    – rubenvb
    Nov 9, 2011 at 13:47
  • $\begingroup$ That's alright. IMHO taking a procedural approach when functional methods are available is a bit of a step backwards, but whatever, right? $\endgroup$ Nov 11, 2011 at 2:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .