excel—write

利用Matlab将数据写入excel文件中:

链接:https://ww2.mathworks.cn/help/matlab/ref/writetable.html

   

  函数:writeable;writeable;writematrix;xlswrite(不推荐)

  语法:

writeable
writeable
writematrix
writetable(T)
writetable(T,filename)
writetable(___,Name,Value)
writecell(C)
writecell(C,filename)
writecell(___,Name,Value)
writematrix(A)
writematrix(A,filename)
writematrix(___,Name,Value)

 

 

 

 

 

 

一、将表写入到电子表格中特定的工作表和范围

  writetable(T,'myData.xls','Sheet',1,'Range','B2:F6')

  注意:T的数据类型是cell

  matlab 数据转换:

  • cell2mat:将cell转换为mat的char型
  • str2num:将mat从char转换为double型
  • cellstr:将char转cell
  • num2str:将double转char
  • num2cell:将double直接转cell
%获取文件夹下所有jpg文件的名称,然后写入excel文件

%获取文件名称
filepath = 'D:\Users\zhuyingdi\Desktop\表彰\*.jpg';
fileinfo = dir(filepath);%获取文件的所有信息

len = length(fileinfo);
write_filename = '11.xls';

for i = 1:len
    T = fileinfo(i).name;
    C = cellstr(T);
    i1 = num2str(i);
    cell = strcat('A',i1);
    writecell(C,write_filename,'Sheet',1,'Range',cell);
end

 

 

posted @ 2020-09-06 17:10  ZYDTT  阅读(532)  评论(0)    收藏  举报