matlab编程|matlab编程 csv到mat格式转换程序

imgDataPath = ''; imgDataDir = dir(imgDataPath); % 遍历所有文件 SonDataPath = ''; for i = 1:length(imgDataDir) if(isequal(imgDataDir(i).name,'.')||... % 去除系统自带的两个隐文件夹 isequal(imgDataDir(i).name,'..')||... ~imgDataDir(i).isdir)% 去除遍历中不是文件夹的 continue; end imgDir = dir([imgDataPath imgDataDir(i).name '/*.csv']); for j =1:length(imgDir)% 遍历所有文件 tempString = imgDir(j).name; %获取文件名称 tempString = tempString(1:7); %去除csv。我这里文件名长度固定 tempString = strcat(tempString,'mat'); SonDataPath1 = strcat(SonDataPath,imgDataDir(i).name); if ~exist(SonDataPath1) mkdir(SonDataPath1); end SonDataPath1 = strcat(SonDataPath1,'/'); SonDataPath1 = strcat(SonDataPath1,tempString); %保存路径 ReadPath = strcat(imgDataPath,imgDataDir(i).name); ReadPath = strcat(ReadPath,'/'); ReadPath = strcat(ReadPath,imgDir(j).name); Data = https://www.it610.com/article/csvread(ReadPath,1,0); %读取csv Datamat = csvtomat(Data); %数据转换save(SonDataPath1,'Datamat'); end end


    推荐阅读