iir_filter

hi,
I want to implement 5th order butterworth 100 mHz lowpass iir filter in arduino. Firstly i ve used matlab sptool for design. Then i found transfer function coefficients of this filter. now, using this coefficients I have to implement the software filter in arduino.
But I didn't do this properly. This is the code I ve written;

float filter( float x) {
  float v[6];
  for(int i=0; i <= 5; i++)
	v[i]=0.0;
    
  
  
  v[0] = v[1];
  v[1] = v[2];
  v[2] = v[3];
  v[3] = v[4];
  v[4] = v[5];
  v[5] = (1.282581078961e-3 * x)
	+ (  0.1254306222 * v[0])
	+ ( -0.8811300754 * v[1])
	+ (  2.5452528683 * v[2])
	+ ( -3.8060181193 * v[3])
	+ (  2.9754221097 * v[4]);
return 
	(v[0] + v[5])
	+5 * (v[1] + v[4])
	+10 * (v[2] + v[3]);
}


float analog=A0,output=A1;
float voltage,x,y;

void setup () {

  
  Serial.begin(9600);
  //Serial1.begin(19200);
  
 
}
void loop() {
  x=0.0;
  x=analogRead(analog);
  voltage=(x/1023.0)*5.0;
  //Serial.println(voltage);
  output=filter(x);
  
  Serial.println(output);
  
  
  }

This part isn't correct:

float filter( float x) {
  float v[6];
  for(int i=0; i <= 5; i++)
	v[i]=0.0;

You declare new array each time when you passing new value, so all history is lost. I think you should declare v[6] as global and remove "for" initializing loop.

You should declare float v[6] as static so it persists between calls to your filter function. You can't initialize v[6] to all zeros with each call as you are doing. It would help if you included a diagram of your filter with your post so that readers could get an idea of what you are trying to do.