Check if a vector and matrix are orthogonal (MATLAB)
Show older comments
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)
high speed
on 25 Mar 2022
Edited: high speed
on 25 Mar 2022
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.'
As you can see, this also results in a real scalar (but only if G_sys and H_sys are equal).
high speed
on 25 Mar 2022
Rik
on 25 Mar 2022
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.
Answers (1)
Mohammed Hamaidi
on 25 Mar 2022
0 votes
See this :Low-density_parity-check_code
Orthogonality mean 'mod 2=0'
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!