Effacer les filtres
Effacer les filtres

i am executing the code below and getting the error"Subscript indices must either be real positive integers or logicals"Error in decalage (line 5) z(1:s-1,1:​s-1)=y((p-​s+2):p,(p-​s+2):p);

1 vue (au cours des 30 derniers jours)
if true
function [mrx]=reconst_mat(zz1,zz2,zz3,zz4,filter)
%zz1=zz1*2;zz2=zz2*2;zz3=zz3*2;zz4=zz4*2;
[hh1,hh2,gg1,gg2] = wfilters(filter);
[d1,d]=size(hh1);
for i=1:d
h1(i)=hh1(d-i+1);
h2(i)=hh2(d-i+1);
g1(i)=gg1(d-i+1);
g2(i)=gg2(d-i+1);
end
[p1,p2]=size(zz1);
[s1,s2]=size(g1);
k=1;
for i=1:p1
z1(k,:)=zz1(i,:);z1(k+1,:)=0;
z2(k,:)=zz2(i,:);z2(k+1,:)=0;
z3(k,:)=zz3(i,:);z3(k+1,:)=0;
z4(k,:)=zz4(i,:);z4(k+1,:)=0;
k=k+2;
end
m1=mat1(p1*2,p2*2,g1);
m2=mat1(p1*2,p2*2,g2);
y1=m1*z1; y2=m2*z2; y3=m1*z3; y4=m2*z4;
yy1=y1+y2;
yy2=y3+y4;
clear y1 y2 y3 y4
k=1;
for i=1:p2
x1(:,k)=yy1(:,i);x1(:,k+1)=0;
x2(:,k)=yy2(:,i);x2(:,k+1)=0;
k=k+2;
end
%clear m1 m2
m1=mat2(p1*2,p2*2,g1);
m2=mat2(p1*2,p2*2,g2);
y1=x1*m1;
y2=x2*m2;
mrx=y1+y2;
mrx=decalage(mrx,g1);
function [z]=decalage(y,h)
[s1,s]=size(h); %s1=1, s=10
[p,p]=size(y);% p=4*4
z(1:s-1,1:s-1)=y((p-s+2):p,(p-s+2):p);%z(1 to 9,1 to 9)=y((-4:4,-4:4)
z(s:p,s:p)=y(1:(p-s+1),1:(p-s+1));
z(s:p,1:(s-1))=y(1:p-s+1,p-s+2:p);
z(1:s-1,s:p)=y(p-s+2:p,1:p-s+1);
end
%--------------------------------------------------
value of mrx is below.
mrx =
-5.1067 0.3892 -0.1582 0.6983
0.3176 0.1933 0.0948 0.2082
-0.8990 0.0894 0.9918 0.3191
0.6711 0.1703 0.2539 0.1011
K>> g1
g1 =
Columns 1 through 5
0 0 -0.0645 -0.0407 0.4181
Columns 6 through 10
0.7885 0.4181 -0.0407 -0.0645 0
  1 commentaire
John D'Errico
John D'Errico le 18 Mar 2015
Modifié(e) : John D'Errico le 18 Mar 2015
Why cannot you learn to format your code to be readable? Select it as you paste it in, THEN CLICK ON THE "{} Code" button. Otherwise, your code becomes one strung out, unreadable mess. And given that this code is already an unreadable mess, why not help out those who might answer your question?

Connectez-vous pour commenter.

Réponses (1)

John D'Errico
John D'Errico le 18 Mar 2015
Your title tells us that the error occurs in decalage (line 5)
z(1:s-1,1:s-1)=y((p-s+2):p,(p-s+2):p);
so what are s and p?
The answer is trivial once you tell us. You should know it yourself by then too. So tell us, without our being forced to try to run this code ourselves, what are s and p? (I could not even attempt to run it anyway, since I lack the function wfilters.)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by