How can I implement this code several stages??

I want to compute 15 stages of the my output , my problem is in the second loop, is it correct?? i want to implement yi+1(n) = yi(n) * wi+1 ie: y1(n) is the first stage and so on...when i run it i get Index exceeds matrix dimensions. error in y(i+1,:)=y(i)*w(i+1,:);
also, how can i plot the fourth stage??? thank you for the help.
% w = estimated FIR filter
% y = output array y(n)
% x = input array x(n)
% d = desired array d(n), length must be same as x
% mu = step size
% M=order of the filter;
N=300;
n=1:N;
M=4;
d(n) = sin(0.2*pi*n);
sigma = 0.5;
v(n) =sigma*randn(1,N);
x(n)= d+v; N=length(x);
subplot(311); plot(d(n))
mu=0.01; subplot(312); plot(x(n))
w=zeros(1,M); w1=zeros(1,M);e=zeros(1,N);y=zeros(1,N);
for n=M:N
x1=x(n:-1:n-M+1);
y(n) = w*x1';
e = d(n)-y(n);
w = w +mu*e*x1;
w1(n-M+1,:)=w(1,:);
end
% I is number of stages
I=15;
for i=2:I
y(i+1,:)=y(i)*w(i+1,:);
end

8 comentarios

dpb
dpb el 22 de Sept. de 2019
M and d are undefined for starters...
KALYAN ACHARJYA
KALYAN ACHARJYA el 22 de Sept. de 2019
Editada: KALYAN ACHARJYA el 22 de Sept. de 2019
Please provide the complete information (all input data) to get the exact solution.
Adam Danz
Adam Danz el 23 de Sept. de 2019
Still not enough information.
We need a working example so we can run your code. There are missing variable values and the code in your comment above is not executable. To move forward, provide a functional code that you've tested and we can copy-paste into our environment.
We still can't run the code.
Unrecognized function or variable 'M1'.
Error in jff (line 18)
x1=x(n:-1:n-M1+1);
Good mind
Good mind el 14 de Oct. de 2019
Sorry, it is typo. it is M not M1
M=4;
w=zeros(1,M);
okay so w is 1 x 4
w = w +mu*e*x1;
mu and e are scalars and x1 is 1 x 4, so w stays 1 x 4
I=15;
for i=2:I
y(i+1,:)=y(i)*w(i+1,:);
end
That asks for row number 2+1=3 of w, but w only has 1 row.
Good mind
Good mind el 14 de Oct. de 2019
Is the second loop correct???? in my case:the future out put is dependent on the present out put and the future filter
Walter Roberson
Walter Roberson el 14 de Oct. de 2019
How can it be correct when you are asking for multiple rows of w when w only has one row?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Communications Toolbox en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 22 de Sept. de 2019

Comentada:

el 14 de Oct. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by