Check if a vector and matrix are orthogonal (MATLAB)

Dear,
I founded this program:
clear;clc;
Niter = 2; % number of iterations
EsN0_dB = -3:1:7; % SNR range to plot over
msg_num = 2000; % number of messages per SNR value
H =[1 1 1 1 0 0 0 0 0 0;
1 0 0 0 1 1 1 0 0 0;
0 1 0 0 1 0 0 1 1 0;
0 0 1 0 0 1 0 1 0 1;
0 0 0 1 0 0 1 0 1 1];
[rows, cols] = size(H);
[G_sys, H_sys] = gen_Gsys_from_H(H);
check = mod(G_sys*H_sys',2); % to see if orthogonal
But I don't have the function gen_Gsys_from_H(H)
I want just to understand if G_sys in this case is a vector or matrix. And what the result check must be to see if it is orthogonal or not ?

5 Comments

When looking up the source of this code (which you could have linked to as well), I found a reference:
"LDPC using Gallager's method in log probability domain rewritten by In Soo Ahn on Feb. 23, 2007 Modified May 20, 2008 Modified April 8, 2013 by Matthew Pregara"
Have you tried looking that up?
The only thing we can conclude is that this could will only run without error if G_sys has the same number of columns as H_sys. I would suspect check is a scalar, so that would mean both are 1-by-n vectors.
[G_sys, H_sys] = deal(randi([0 1],[1 3]));
check = mod(G_sys*H_sys',2)
check = 1
@Rik Please what is the meaning of [1 3] in this line:
[G_sys, H_sys] = deal(randi([0 1],[1 3]))?
beacause if we consider the number of columns in this matrix it's 10 not 3, so why did you choose 3 ?
and the result check must be 0 or 1 ? as @Mohammed Hamaidi we must find the result 0 no ?
I did not search for the actual code. I just looked at the last line and created arrays that would work with that code. The only thing I actually claimed is that the two arrays must be 1-by-n. What the value of n is, is not clear from the code itself. It could be 10, but there is no reason in Matlab itself that it should be. Perhaps the number of columns in H determines the number of columns in H_sys, but that is not required for this code to run without errors.
Note that there is another option: the apostrophe is the complex conjugate, not just a transpose. For real numbers the difference is non-existent, but for complex values there is a difference:
a= 1 + i*2;
a*a' , a*a.'
ans = 5
ans = -3.0000 + 4.0000i
As you can see, this also results in a real scalar (but only if G_sys and H_sys are equal).
The number of columns in this example is 10, but I didn't understand why did you choose 3. Also, H_sys is normally a matrix, but in the line that you wrote you have considered H_sys as a vector not a matrix. As I have understand that to confirm if it is orthogonal or not we must have mod-2=0 of the product between the vector and the transposed matrix. So normally G_sys is a vector and H_sys is a vector no?
I don't know anything about your application. What I told you is what you can learn from the code itself. If the variable check must be a scalar, then those two other variables must be vectors. Matlab doesn't care about the length, as long as they're equal. I don't know what that function was supposed to do, that is why I posted a comment, not an answer.

Sign in to comment.

Tags

Asked:

on 25 Mar 2022

Commented:

Rik
on 25 Mar 2022

Community Treasure Hunt

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

Start Hunting!