필터 지우기
필터 지우기

[Beginner] MATLAB : Error ??? Index exceeds matrix dimensions but I can't fix it

조회 수: 1 (최근 30일)
Yassine Bouchdoug
Yassine Bouchdoug 2015년 12월 4일
댓글: Yassine Bouchdoug 2015년 12월 4일
Hi all, I'm just a beginner in Matlab and I need help about an issue in my program. When I try to run my program, I have one of the following error : ??? Index exceeds matrix dimensions in those lines :
Error in ==> reseau_capteur_def at 70 mesg_decod(3,:)=xor(xor(zb_gt(7,:),zb_gt(2,:)),zb_gt(4,:));
Error in ==> reseau_capteur_def at 74 mesg_decod(4,:)=xor(xor(zb_gt(7,:),zb_gt(2,:)),zb_gt(3,:));
Error in ==> reseau_capteur_def at 65 mesg_decod(2,:)=xor(xor(zb_gt(7,:),zb_gt(3,:)),zb_gt(4,:));
Can you help me to solve this please? Because I'm still a beginner in Matlab and I spent a whole week trying to solve this but with no success, and thank you in advance for your help.
Here's a part of the program where the error occurs (and the whole program if attached to this message):
% on réencode en utilisant le codage
y_trans(1,:)=xor(zdec_rel(1,:),zdec_rel(2,:));
y_trans(2,:)=xor(xor(zdec_rel(1,:),zdec_rel(3,:)),zdec_rel(4,:));
y_trans=2*y_trans-1;
%signal reçu à la gateway depuis le relais
for ii=1:2
z_gt(ii,:)=awgncomplex(1,length_msg,SNR(1,m),HH_rel_gt*y_trans(ii,:));
end
% On égalise les signaux au niveau de la gateway
for ii=1:N_capteurs
zz_gt(ii,:)=conj(HH_sens_gt(1,ii))*y_gt(ii,:)/(abs(HH_sens_gt(1,ii)))^2;
end
for ii=1:2
za_gt(ii,:)=conj(HH_rel_gt)*z_gt(ii,:)/(abs(HH_rel_gt))^2;
end
zb_gt=[0.5*(sign(real(zz_gt))+1);0.5*(sign(real(za_gt))+1)];
zb_gt(out_pk(1,1),:)=zeros(1,length_msg);
zb_gt(out_pk(1,2),:)=zeros(1,length_msg);
%zb_gt
% L'algorithme de décodage commence ici, on distingue les différents cas
if ((out_pk(1,1)==1) & (out_pk(1,2)==2))
mesg_decod(1,:)=xor(xor(zb_gt(6,:),zb_gt(3,:)),zb_gt(4,:));
mesg_decod(2,:)=xor(xor(zb_gt(7,:),zb_gt(3,:)),zb_gt(4,:));
mesg_decod(3,:)=zb_gt(3,:);
mesg_decod(4,:)=zb_gt(4,:);
elseif ((out_pk(1,1)==1) & (out_pk(1,2)==3))
mesg_decod(1,:)=xor(xor(zb_gt(5,:),zb_gt(2,:)),zb_gt(4,:));
mesg_decod(3,:)=xor(xor(zb_gt(7,:),zb_gt(2,:)),zb_gt(4,:));
mesg_decod(2,:)=zb_gt(2,:);
mesg_decod(4,:)=zb_gt(4,:);
elseif ((out_pk(1,1)==1) & (out_pk(1,2)==4))
mesg_decod(4,:)=xor(xor(zb_gt(7,:),zb_gt(2,:)),zb_gt(3,:));
mesg_decod(1,:)=xor(xor(zb_gt(5,:),zb_gt(2,:)),mesg_decod(4,:));
mesg_decod(2,:)=zb_gt(2,:);
mesg_decod(3,:)=zb_gt(3,:);
elseif ((out_pk(1,1)==2) & (out_pk(1,2)==3))
mesg_decod(2,:)=xor(xor(zb_gt(5,:),zb_gt(1,:)),zb_gt(4,:));
mesg_decod(3,:)=xor(xor(zb_gt(6,:),zb_gt(1,:)),zb_gt(4,:));
mesg_decod(1,:)=zb_gt(1,:);
mesg_decod(4,:)=zb_gt(4,:);
elseif ((out_pk(1,1)==2) & (out_pk(1,2)==4))
mesg_decod(4,:)=xor(xor(zb_gt(6,:),zb_gt(1,:)),zb_gt(3,:));
mesg_decod(2,:)=xor(xor(zb_gt(5,:),zb_gt(1,:)),mesg_decod(4,:));
mesg_decod(1,:)=zb_gt(1,:);
mesg_decod(3,:)=zb_gt(3,:);
else
mesg_decod(4,:)=xor(xor(zb_gt(5,:),zb_gt(1,:)),zb_gt(2,:));
mesg_decod(3,:)=xor(xor(zb_gt(6,:),zb_gt(1,:)),mesg_decod(4,:));
mesg_decod(1,:)=zb_gt(1,:);
mesg_decod(2,:)=zb_gt(2,:);
end

답변 (1개)

Thorsten
Thorsten 2015년 12월 4일
편집: Thorsten 2015년 12월 4일
What does
size(zb_gt)
return before those lines? Presumably it has to few rows.
  댓글 수: 1
Yassine Bouchdoug
Yassine Bouchdoug 2015년 12월 4일
Hi and thank you for your answer,
When I try to do the size(zb_gt) it gives me (7 lines 200 columns) : ans =
7 200
You can find the whole program (with the instructions before those on the message) attached to the message, do not hesitate to look it up for a better understanding of it (and don't worry it's not a very long program :) ).

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by