void filterData(float[] filteredData, float[] yVals, int filterThreshold) {
for (int i=1; i<yVals.length-1; i++) {
float average = 0.0;
float runningTotal = 0.0;
int sampleCount = 0;
while (abs(yVals[i]-yVals[i-1])<filterThreshold) {
runningTotal += yVals[i];
sampleCount++;
}
average = runningTotal/sampleCount;
for (int j=i; j<sampleCount; j--) {
filteredData[j] = average;
}
}
}
What I am trying to do can be illustrated by this figure:
If the difference between the next value and current value is greater than threshold, calculate the average value in the current segment and assign it as filtered data.
I am sure something is wrong with the code as it crashes when I run it!
Here I have made a plot from the D_W array and time array.
Is there a way to find the exact point (time array index) at which the transitions from positive to negative or vice versa take place?
Example:
Looking from left to right you can see the graph changes from positive to negative so I need to find that point in between the 2 opposing peaks. I then need to find the same points for each pair of peaks further along the plot.
I have been thinking about how to do this for a while but just ran out of idea.
I am basically writing a txt file as an output of a program. It works when i run the program in my local drive and I get the txt out file in the local folder.
The question is if I upload the program to the web, are there any ways I can still retrieve the output txt file when running the applet?
I saw the setVisible function for PShape but I wonder if there is a similar function if I want to set it on a rect().
The reason I want this is because I want a rectangle to act as a cover in a specific area on screen and I can choose to hide (rect visible = true) or unhide (rect visible =false). So basically the rectangle covers what is underneath it.
im trying to avoid making a PShape just for this .