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

1 view (last 30 days)
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 Comment
Jan
Jan on 1 Oct 2011
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...

Sign in to comment.

Answers (2)

Jan
Jan on 1 Oct 2011
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 on 8 Oct 2011
Got a question.. Where should I input dbstop if error throughout my program????

Community Treasure Hunt

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

Start Hunting!