Hi,
in a my hold post i asked "how write a code for FIFO buffer". this wasn't correct because i doesn't need of FIFO buffer but of "rotative array".
I know that it isn't correct but my problem isn't resolved....
My (hold) problem is this below:
I have two array where will put samples.
-pressure;
-time;
So, i will filter my samples with "least squares" method. For this, in the vector of time, i need that the first element of time vector is ever "0". When i shift this vector to left, the second element will be "0" and will be put in the first cell.
However i need de temporal distance between the first element (that will be "0") and other elements!
#define n_samples 50 //number of samples
float time_vect[n_samples]; //vector of time
float first_value;
void setup() {
//[...] setup
}
void loop() {
for(int c = 0; c< n_samples; c++) time_vect[c] = time_vect[c+1];
time_vect[n_samples-1] = millis()-time_vect[0];
first_value = time_vect[0];
for(int c = 0; c< n_samples-2; c++) time_vect[c] -first_value;
//[...] program
}
in this mode, time_vect[0] will be ever the tempora origin and, for example, temp_vect[8] will be the temporal distance between time_vect[0] and time_vect[8]. I'm not shure that this is correct....
is it a good method for my task??