只需要填写输入的路径与输出的路径即可。
clear all;clc;
root = 'C:\Users\ZRZ\Desktop\UATmat\';
dst = 'C:\Users\ZRZ\Desktop\UAT\';
if ~exist(dst, 'dir')
mkdir(dst);
end
% 下面这几句是为了获取一个目录下的txt文件名列表
fileFolder = fullfile(root);
dirOutput = dir(fullfile(fileFolder, '*.txt'));
fileNames={dirOutput.name}; % 1*100 cell
numFile = length(fileNames);
for idxFile = 1:numFile
path = [root fileNames{idxFile}];
res = load(path);
[seq_l, xywh] = size(res);
results{1}.res = res;
results{1}.type = 'rect';
results{1}.len = seq_l;
seq_name = fileNames{idxFile}(1:end-4);
sprintf(['now trans ' seq_name ' from txt to mat'])
% 将需要的结构体结果写成mat格式
save([dst seq_name '_UAT.mat'], 'results');
end