From: darren on
I have the following code for a feedforward filter circuit

clear all
x = 1;
a=[0.1;0.4;0.3]
for n=2:length (a);
y(n)=a(1)*x*(n)+ a(2)*x*(n-1)+ a(3)*x*(n-2)
end
plot(y)

Could someone let me know if this is correct. The question for the code is below.
I am unsure about "Your circuit should accept any size input."


Write a MATLAB program, using basic programming constructs, that simulates a discrete feed forward circuit with 2 coefficients and then 3 coefficients use, a = 0.3, 0.4 and a = 0.1,0.4,0.3. Assume the first coefficient represent zero delay. Your circuit should accept any size input.