- 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)
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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:
% 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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!