# Plot[] breaks behavior of custom data handling function - Recursion

I am working on a utility to analyze a set of data. I want to process the data with a sliding window, in such a way that there is an output associated with each sample of data.

To start, I have a list of data: MyData

I've defined the following utility function to pull 10 consecutive samples of data from MyData starting at an arbitrary location within MyData.

EvalWin[x_] := Take[MyData, {x, x + 9}];


This works.

Now lets say I have a processing function that sums the 10 samples.

ProcData[x_] := Total[EvalWin[x]];


This also works.

The problem comes if I attempt to use ProcData[] as an argument to a built in Mathematica function such as Plot.

For example if I attempt to plot ProcData[] for a set of 100 samples...

Plot[ProcData[x], {x, 10, 110}]


The Plot function blows up due to recursion.

Are there ways to control how built in functions handle data to avoid recursive blow up, or is there a more Mathematica friendly way to accomplish this kind of data manipulation?

-
 It is not a good idea to use global variables in functions. In your EvalWin[x_] := Take[MyData, {x, x + 9}] You should pass everything via parameters to functions, including MyData. Also, not a good idea to use first letter UpperCase for variable names. – Nasser Feb 11 at 4:35 Your problem isn't recursion, it's the fact that array indices have to be positive integers and Plot assumes a continuous variable. – Jens Feb 11 at 4:56 By the way, in case you're really interested in something like what your example does, maybe take a look at MovingAverage – Jens Feb 11 at 5:10

Use DiscretePlot[] instead for integer-valued functions:
ProcData[x_Integer] := Sum[MyData[[k]], {k, x, x + 9}]

 This (+1), or ListPlot seem to be the most appropriate solutions. Or one could stick with Plot and replace ProcData[x] with ProcData[Floor[x]]. – Jens Feb 11 at 4:54 So the issue is really in the need to establish that I am working with an integer. Thanks. – Bruce Zenone Feb 11 at 13:25