Create continuous function from list - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-09-17T05:19:13Z https://mathematica.stackexchange.com/feeds/question/30360 https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/30360 2 Create continuous function from list Wiebe https://mathematica.stackexchange.com/users/9022 2013-08-13T12:46:37Z 2013-08-13T13:30:43Z <p>I have a list of data (measured per day) that I want to use as imput for another equation (say f). The problem is that the input I need for f needs to be a continuous function of time. Is it possible to change my data into a function? I would either like a function that is linear increasing or decreasing between the different timesteps (like the line you get when you use <code>Joined</code> in <code>ListPlot</code>) or a stepwise function that immediately jumps to another value the next day.</p> <p>I tried using <code>Interpolate</code> but then when I measured 0, I get negative values which is not possible for my measured values. </p> <p>Hope someone could help me.</p> <p>Simplified example:</p> <pre><code>tmin=1; tmax=6; data = {{1, 3}, {2, 0}, {3, 0}, {4, 5}, {5, 7}, {6, 10}}; ListPlot[data, AxesLabel -&gt; {"time(day)", "data(mm)"}, Joined -&gt; True] f = Interpolation[data]; Plot[Evaluate[f[t]], {t, tmin, tmax}] </code></pre> <p>If you evaluate this: the first plot is the result I would prefer for my function, the second plot is not what I want as the values drop below 0.</p> <p><img src="https://i.stack.imgur.com/nxFAO.png" alt="enter image description here"></p> https://mathematica.stackexchange.com/questions/30360/-/30361#30361 4 Answer by Dr. belisarius for Create continuous function from list Dr. belisarius https://mathematica.stackexchange.com/users/193 2013-08-13T12:51:25Z 2013-08-13T12:51:25Z <pre><code>data = {{1, 3}, {2, 0}, {3, 0}, {4, 5}, {5, 7}, {6, 10}}; f = Interpolation[data, InterpolationOrder -&gt; 1]; GraphicsRow[{Plot[f[t], {t, 1, 6}, AxesOrigin -&gt; {-1, -1}], ListPlot[data, Joined -&gt; True, AxesOrigin -&gt; {-1, -1}]}] </code></pre> <p><img src="https://i.stack.imgur.com/sJ0qU.png" alt="Mathematica graphics"></p>