将simulink输入输出信息导出到excel脚本

此脚本可以提取simulink的inport与outport的信号名称、数据类型等信息并将其导出到excel表中。 

clear;

str1 = 'ASW';
ASD = {''};
xlswrite('lingshi',ASD,'sheet1','A1:I1000'); %清空表格
biaotou = {'信号名称','描述','数据类型','访问方式','源/目的','单位','分辨率','最小值','最大值'};
xlswrite('lingshi',biaotou,'sheet1','A1'); %写入表头

Outport=find_system(gcs,'SearchDepth',1,'FindAll','on','BlockType','Outport'); %获取模型输出端口信息
Inport=find_system(gcs,'SearchDepth',1,'FindAll','on','BlockType','Inport'); %获取模型输入端口信息

for i = 2:length(Inport) %输入口第一个为激活信号,所以从2开始
    modelname = get_param(Inport(i),'Name'); %名称
    modelPath = get_param(Inport(i), 'Description'); %描述
    modeldata = get_param(Inport(i),"DataType"); %信号类型
    modeltype = get_param(Inport(i),"BlockType"); %输入or输出
    result = [str1, modeltype];
    modelorgin = get_param(Inport(i),"Unit"); %单位
    modelmin = get_param(Inport(i),"OutMin"); %最小值
    modelmax = get_param(Inport(i),"OutMax"); %最大值
    model = {modelname,modelPath,modeldata,result,{' '},modelorgin,{' '},modelmin,modelmax}; %生成元组
    mRowRange = num2str(i); %数组长度转化为字符串
    AB = strcat('A', mRowRange); %拼接表格输入位置信息
    xlswrite('lingshi',model,'sheet1',mRowRange); %将元组信息写入表格
end
for j = 1:length(Outport)
    modelname = get_param(Outport(j),'Name');
    modelPath = get_param(Outport(j), 'Description');
    modeldata = get_param(Outport(j),"DataType");
    modeltype = get_param(Outport(j),"BlockType");
    result = [str1, modeltype];
    modelorgin = get_param(Outport(j),"Unit");
    modelmin = get_param(Outport(j),"OutMin");
    modelmax = get_param(Outport(j),"OutMax");
    model = {modelname,modelPath,modeldata,result,{' '},modelorgin,{' '},modelmin,modelmax};
    mRowRange = num2str(i+j);%数组长度转化为字符串
    AB = strcat('A', mRowRange);
    xlswrite('lingshi',model,'sheet1',mRowRange);
end
warndlg('数据生成成功.', '提示');

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值