writesparse.m

来自「压缩文件中是Error Correction Coding - Mathemat」· M 代码 · 共 24 行

M
24
字号
function writesparse(A,fp)% function writesparse(A,fp)%% Write the binary matrix A into the file fp% in MacKay's sparse format% Todd Moon% Copyright 2004 by Todd K. Moon% Permission is granted to use this program/data% for educational/research only[m,n] = size(A);fprintf(fp,'%d %d\n',n,m);   % dimensions of Afprintf(fp,'%d %d\n',max(sum(A,1)),max(sum(A,2)));  % max column and row weightsfprintf(fp,'%d ',sum(A,1)); fprintf(fp,'\n');  % column weights (array)fprintf(fp,'%d ',sum(A,2)); fprintf(fp,'\n');  % row weights (array)for i=1:n  % write out the nonzero positions in each column  fprintf(fp,'%d ',find(A(:,i)));  fprintf(fp,'\n');endfor i=1:m  % write out the nonzero positions in each row  fprintf(fp,'%d ',find(A(i,:)));  fprintf(fp,'\n');end

⌨️ 快捷键说明

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