matlab读.mat写入txt

问题:

读VehicleInfo.mat里面的数据,存入一个.txt文件中

代码:

load('VehicleInfo.mat');
sz = size(VehicleInfo);
nums = sz(1);

anno = VehicleInfo;
fout=fopen('bit_vehicles_anno.txt', 'w');
for i=1:nums
    name = anno(i).name;
    height = anno(i).height;
    width = anno(i).width;
    vehicles = anno(i).vehicles;
    nVehicles = anno(i).nVehicles;
    for j=1:nVehicles
        left = num2str(vehicles(j).left);
        top = num2str(vehicles(j).top);
        right = num2str(vehicles(j).right);
        bottom = num2str(vehicles(j).bottom);
        cls_name = vehicles(j).category;
        %fprintf(fout, '%s;%d;%d;%d;%d;%d;%d;%s\n',
        %    name, height, width, left, top, right, bottom, cls_name);
        outline = [name, ';', left, ';', top, ';', right, ';', bottom, ';', cls_name, '\n'];
        fprintf(fout, outline);
    end
end
fclose(fout);

 

posted @ 2020-02-24 14:28  皮卡皮卡妞  阅读(589)  评论(0编辑  收藏  举报