其他分享
首页 > 其他分享> > 学习笔记154—Matlab 如何写入txt?

学习笔记154—Matlab 如何写入txt?

作者:互联网

fid_pos_in = fopen('E:\coupling_FC_SC_ASD\child_adol_2514\adol\test_pos_in.txt','w');
fid_pos_ex = fopen('E:\coupling_FC_SC_ASD\child_adol_2514\adol\test_pos_ex.txt','w');
fid_neg_in = fopen('E:\coupling_FC_SC_ASD\child_adol_2514\adol\test_neg_in.txt','w');
fid_neg_ex = fopen('E:\coupling_FC_SC_ASD\child_adol_2514\adol\test_neg_ex.txt','w');
for t = 1 : size(col,1)
    zVal = v(t,1);
    r_c_val = {};
    if zVal > 0
        r_c_val = [row_net(t,:),col_net(t,:)];
        if strcmp(r_c_val(1,1), r_c_val(1,4))
            fprintf(fid_pos_in,'%s %d %d %s %d %d\r\n',r_c_val{1,:});
        else
            fprintf(fid_pos_ex,'%s %d %d %s %d %d\r\n',r_c_val{1,:});
        end
    elseif zVal < 0
        r_c_val = [row_net(t,:),col_net(t,:)];
        if strcmp(r_c_val(1,1), r_c_val(1,4))       
            fprintf(fid_neg_in,'%s %d %d %s %d %d\r\n',r_c_val{1,:});
        else
            fprintf(fid_neg_ex,'%s %d %d %s %d %d\r\n',r_c_val{1,:});
        end
    end
end
fclose(fid_pos_in);
fclose(fid_pos_ex);
fclose(fid_neg_in);
fclose(fid_neg_ex);

标签:adol,154,val,neg,pos,Matlab,fid,txt,ex
来源: https://www.cnblogs.com/hechangchun/p/12752007.html