matlab将二维数组写入C语言格式,并存入txt文件

w=zeros(500,500);
w=load('parameter\w.txt');
fid=fopen("esn_w.txt","w");
[aa,bb]=size(w);
for i=1:aa
    for j=1:bb
        fprintf(fid,"%d,",w(i,j));
    end
    fprintf(fid,";");
    fprintf(fid,"\n");
end
fclose(fid);

你可能感兴趣的:(算法)