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?
EvalWin[x_] := Take[MyData, {x, x + 9}]You should pass everything via parameters to functions, includingMyData. Also, not a good idea to use first letter UpperCase for variable names. – Nasser Feb 11 at 4:35Plotassumes a continuous variable. – Jens Feb 11 at 4:56