# Construction of a matrix from other (MATLAB)

3 Ansichten (letzte 30 Tage)
Afluo Raoual am 28 Apr. 2023
Bearbeitet: Afluo Raoual am 5 Mai 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 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

LeoAiE am 28 Apr. 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 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by