Construction of a matrix from other (MATLAB)

3 vues (au cours des 30 derniers jours)
Afluo Raoual le 28 Avr 2023
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 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

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:
1. Determine the desired code rate.
2. Calculate the number of extra rows and columns needed to achieve that code rate.
3. Add the extra rows and columns to the matrix H1.
% 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)';
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 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrix Indexing 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!

Translated by