matlab数据批量保存为excel,文件名,行和列的名称设置

Excel文件内数据保存结果如下:

matlab数据批量保存为excel,文件名,行和列的名称设置_第1张图片

Excel文件保存结果如下:

matlab数据批量保存为excel,文件名,行和列的名称设置_第2张图片

代码如下:

clear;clc;
for jjjj=1:10             %这个可以改
jname=(jjjj-1)*10;        %文件名中变数  这是EXCEL文件名字的一部分 根据自己需要改
jkkkk_=num2str(jname);      

for iiii=1:13             %这个可以改
    iname=(iiii-1)*15;    %             这是EXCEL文件名字的一部分 根据自己需要改
    mmmm_=num2str(iname);   
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    ANSWER=rand(5,6);           %这是要保存的数据,可以根据自己需要修改

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    nnnn_=strcat('F:\新建文件夹/','竖直',jkkkk_,'_水平',mmmm_,'_22','.xlsx');  %赋值路径字符
%%%%上面这是保存到F盘新建文件夹里的

%   nnnn_=strcat('F:/','竖直',jkkkk_,'_水平',mmmm_,'_22','.xlsx');  %赋值路径字符
%%%%上面这是保存到F盘里的


    [~,dim]=size(ANSWER);
    ANSWER=num2cell(ANSWER,dim);
    varargin={}; 


    ANSWER_name_v={'第一行';'第二行';'第三行';'第四行';'第五行'};       %单引号里 是每一行的名字  根据自己的需要更改
    ANSWER_name_l={varargin,'第一列','第二列','第三列','第四列','第五列','第六列'};   %单引号里  是每一列的名字  根据自己的需要更改

    ANSWERr=[ANSWER_name_l;ANSWER_name_v,ANSWER];
   

 xlswrite(nnnn_,ANSWERr);

    end
end

你可能感兴趣的:(matlab代码,matlab,算法,青少年编程,矩阵,经验分享,excel)