- Determine the desired code rate.
- Calculate the number of extra rows and columns needed to achieve that code rate.
- Add the extra rows and columns to the matrix H1.
Construction of a matrix from other (MATLAB)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear,
I have a MATLAB code that aims to construct a square regular matrix of such dimensions which depend on the value 'm'.
I want to add a part to this code in order to construct regular matrices with different code rates by adding columns and/or rows to the initial matrix H1 which must still constant, in such a way the final matrix must still regular and the number of ones in each row/column must depend on the code rate. For example, for a matrix with a code rate 3/4, the number of ones in each row must be 4 and in each column must be 3.
0 commentaires
Réponse acceptée
LeoAiE
le 28 Avr 2023
To modify the final matrix H1 to achieve different code rates, you can add extra rows and columns with the required number of ones. Here is a possible way to do it:
% Desired code rate
code_rate = 3/4;
% Determine the number of extra rows and columns needed
num_extra_rows = round((1/code_rate - 1) * m);
num_extra_cols = num_extra_rows;
% Create the extra rows and columns
extra_rows = repmat(eye(m), num_extra_rows, 1);
extra_cols = repmat(eye(m), 1, num_extra_cols);
% Add the extra rows and columns to H1
H1_modified = [H1 extra_cols];
H1_modified = [H1_modified; extra_rows];
% Number of ones in each row/column
ones_c_modified = sum(H1_modified, 1);
ones_r_modified = sum(H1_modified, 2);
% Check if the modified matrix is regular
dvi_modified = sum(H1_modified, 1);
dci_modified = sum(H1_modified, 2)';
[adv_modified, bdv_modified] = hist(dvi_modified, unique(dvi_modified));
[adc_modified, bdc_modified] = hist(dci_modified, unique(dci_modified));
dv_modified = sum((adv_modified ./ sum(adv_modified)) .* bdv_modified);
dc_modified = sum((adc_modified ./ sum(adc_modified)) .* bdc_modified);
if max(dv_modified) == min(dv_modified) && max(dc_modified) == min(dc_modified)
disp('Modified matrix is regular')
else
disp('Modified matrix is irregular')
end
spy(H1_modified);
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!