Construction of a matrix from other (MATLAB)

4 ビュー (過去 30 日間)
Afluo Raoual
Afluo Raoual 2023 年 4 月 28 日
編集済み: Afluo Raoual 2023 年 5 月 5 日
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.

採用された回答

LeoAiE
LeoAiE 2023 年 4 月 28 日
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)';
[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 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by