Index exceeds matrix dimensions-when finding inverse of binary matrix,A

조회 수: 7 (최근 30일)
Synchronie
Synchronie 2011년 10월 1일
Hi.. I am using Galois field to find the inverse of a binary matrix, A and here is my program: _________________________________________________________________
H_matrix=input('Insert the H-matrix:');
H=H_matrix;
[num_rows num_cols]=size(H)
A=H(1:num_rows, 1:num_rows)
B=H(1:num_rows, num_rows+1:end)
% We need to find the inverse of matrix A..
% We set A in the Galois field so as to calculate the inverse using the
% inbuilt matlab function inv()
disp('Setting Matrix A in Galois field');
A_GF=gf(A)
disp('The inverse of matrix A in Galois field is:');
A_inv= inv(A_GF)
disp('The inverse of matrix A in the primitive field is:');
A_invv=double(A_inv.x)
% A*A_inv should equate to an identity matrix..
disp('Verifying.................................................:');
Identity=(A_inv)*A_GF
% Computing the generator matrix
disp('The generator matrix is:');
G=[eye(num_rows) mod(A_invv*B,2)]
%Transpose of generator matrix
disp('The transpose of the generator matrix is:');
GT=transpose(G)
fprintf('The message consists of %d bits\n', num_rows);
message=input('Enter the message bits:');
codeword= mod(GT*message',2)
_________________________________________________________________
The H_matrix I used initially is
H_matrix= [0 1 1 0 0 0;1 1 0 1 0 0;1 0 0 0 1 0;0 1 0 0 0 1]
I need to work with very larger matrices.. When I input a (50,34) H_matrix for example, I get this error message:
??? Index exceeds matrix dimensions
And it's the same for any other huge matrices...
  댓글 수: 1
Jan
Jan 2011년 10월 1일
Please use code formatting - follow the "Markup help" link to learn how to apply the different formats to improve the readability.
It is very helpful, if you post the complete error message, especially to know which line causes the error...

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

답변 (2개)

Jan
Jan 2011년 10월 1일
A standard method to find the cause of bugs is:
dbstop if error
Then Matlab stops when an error occurs and you can inspect the values of the used variables. Using the debugger is even more efficient than asking this powerful forum.

Synchronie
Synchronie 2011년 10월 8일
Got a question.. Where should I input dbstop if error throughout my program????

카테고리

Help CenterFile Exchange에서 Error Detection and Correction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by