⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hammcode.m

📁 Electronic Communication Systems的Matlab源码
💻 M
字号:
function hammcode(m)
%
% n = No of Hamming bits
% m = block length
% Example function call:
% hamming(21)
%

n = 0;
while 2^n < m+n+1,
    n = n+1;
end

hamm=num2str(n);
%
% 2 different ways of displaying the result will be shown
%
disp ('The number of Hamming bits is:  ');

% Note that ,hamm, is a string and can thus be passed directly
% to the MATLAB disp(..) function

disp(hamm)

%Secondly, using the %s modifier, the string ,hamm, can be displayed as shown below
fprintf('\nThe number of Hamming bits is: %s\n',hamm);

%
% Finally, using the %e modifier, the result can be siplayed as shown below
fprintf('\nThe number of Hamming bits is: %d\n',n);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -