Can you check what I did wrong here? (code for finding attenuation value and delay using filter)

1 view (last 30 days)
x = zeros(1,100);
x(1:10) = 1;
x(50:59) = 0.5;
%function x
alph = 0.01:0.01:1;%attenuation value
Td = 1:100;%delay
N=3;
for i = 1:length(alph)
a = alph(i);
for j = 1:length(Td)
td = Td(j);
for k = 0:N;
filter(k*td+1) = (-a)^k; %filter
end
y = conv(x,filter);
E(i,j) = sum(y.^2);
end
end
Hello!
I'm working on filtering echo using Matlab.
so here's code for simple function with delay:49, attenuation:0.5
This is the code for finding appropriate delay and attenuation values assuming we do not know them.
The assignment I'm working on tells me to find the correct values by calculating energy (y(t)^2) for each values of alph and Td.
Out of those energy, minimum value would be the correct delay and attenuation. when I perform this code in matlab, the energy goes up really large which should not be.
I have no idea what I did wrong. and also, how do i find the matrix's position of minimum value?
and equation for the filter I used is: h(t)=sigma (k=0 to N)[(-a)^k Dirac(t-k*td)]
Thanks

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!