Hi I am getting error of unexpected matlab operator in line5 and let me know how to solve it??
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function [y Ny]=convo2(x,Nx,h,Nh)
Ny=Nx+Nh;
for n=0:Ny
y(n+1)=0;
for k+1=1:Nh
for m+1=1:Nx
n=k+m;
y(n+1)=y(n+1)+h(k+1)*x(m+1);
end
end
end
1 commentaire
dpb
le 18 Juin 2014
Format the code, please...
function [y Ny]=convo2(x,Nx,h,Nh)
Ny=Nx+Nh;
for n=0:Ny
y(n+1)=0;
for k+1=1:Nh
for m+1=1:Nx
n=k+m;
y(n+1)=y(n+1)+h(k+1)*x(m+1);
end
end
end
Réponses (2)
dpb
le 18 Juin 2014
...
for k+1=1:Nh
for m+1=1:Nx
...
are illegal syntax. If you mean for k and m to start from 2, then write the loop over
for k=2:Nh-1
etc., or recast similarly as to your loop over n
NB: the assignment to y() inside the loop w/o preallocating will be very inefficient.
0 commentaires
Star Strider
le 18 Juin 2014
You actually have two problems:
for k+1=1:Nh
for m+1=1:Nx
This is not a permitted construction.
Restate them as:
for k=1:Nh
for m=1:Nx
and adjust your subscript indices to get the result you want.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!