打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
simulink.bus的定义和使用
  1. Simulink.bus的定义

        BusDemo = Simulink.Bus;
        BusDemo.Description = '';
        BusDemo.DataScope = 'Exported';
        BusDemo.HeaderFile = '';
        BusDemo.Alignment = -1;
       
        busElement1 = Simulink.BusElement;
        busElement1.name = 'busElement1';
        busElement1.Complexity = 'real';
        busElement1.Dimensions = 1;
        busElement1.DataType = 'uint32';
        busElement1.Min = [];
        busElement1.Max = [];
        busElement1.DimensionsMode = 'Fixed';
        busElement1.SamplingMode = 'Sample based';
        busElement1.SampleTime = -1;
        busElement1.DocUnits = '';
        busElement1.Description = '';
       
        busElement2 = Simulink.BusElement;
        busElement2.name = 'busElement2';
        busElement2.Complexity = 'real';
        busElement2.Dimensions = 240;
        busElement2.DataType = 'uint8';
        busElement2.Min = [];
        busElement2.Max = [];
        busElement2.DimensionsMode = 'Fixed';
        busElement2.SamplingMode = 'Sample based';
        busElement2.SampleTime = -1;
        busElement2.DocUnits = '';
        busElement2.Description = '';
     
        BusDemo.Elements = [busElement1 busElement2];
        assignin( 'base', 'busDemo', BusDemo);

  2. 在s-function(c语言)中,注册simulink.bus 并设置端口类型。

        nameBusStr = “busDemo”;

        DTypeId dataTypeIdReg;
        ssRegisterTypeFromNamedObject(
            S,
            nameBusStr,
            &dataTypeIdReg);
        if (dataTypeIdReg == INVALID_DTYPE_ID)
                return;
       /*mexPrintf("nameBusStr:  %s\n",nameBusStr);*/   
        ssSetOutputPortDataType(S, 1, dataTypeIdReg );


        ssSetBusObjectName(S, 1, (void *)nameBusStr);
        ssSetBusOutputAsStruct(S, 1, 1);

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
怎样生成我想要的C代码系列 | 如何定义结构体
Matlab/Simulink建模规范(3)— 信号的处理
怎样生成我想要的 C 代码系列(14)
枚举显示中文问题
Simulink模块库简介(7)(8)
各种主板跳线说明
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服