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

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

Excel文件保存结果如下:

代码如下:

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值