📄 hammcode.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 + -