matlab创建结构体

文章介绍了如何用M语言创建Simulink的参数,如设置最大索引、断点和数据表,并且展示了如何创建Bus对象,定义其数据类型和元素。此外,提到了使用Modelexplorer的方法,但未详细展开。
摘要由CSDN通过智能技术生成

m语言

参数

p = Simulink.Parameter;
p.Value.MaxIdx = [2 2];
p.Value.BP1 = [1 2 3];
p.Value.BP2 = [1 4 16];
p.Value.Table = [4 5 6; 16 19 20; 10 18 23];
p.DataType = 'Bus: slLookupTable';
p.CoderInfo.StorageClass = 'ExportedGlobal';

% Create bus object slBus1 from MATLAB structure
Simulink.Bus.createObject(p.Value);
slLookupTable = slBus1;
slLookupTable.Elements(1).DataType = 'uint32';

生成结构体如下:
在这里插入图片描述

信号

% struct for signal
Struct = Simulink.Bus;

BusElements{1}(1,1) = Simulink.BusElement;
BusElements{1}(1,1).Name = 'Value';
BusElements{1}(1,1).DataType = 'uint8';
BusElements{1}(2,1) = Simulink.BusElement;
BusElements{1}(2,1).Name = 'Status';
BusElements{1}(2,1).DataType = 'boolean';
BusElements{1}(3,1) = Simulink.BusElement;
BusElements{1}(3,1).Name = 'Stamp';
BusElements{1}(3,1).DataType = 'uint8';

Struct.Elements = BusElements{1};
Struct.DataScope = 'Exported';
%define signal datatype
s.DataType = 'Bus: Struct';

model explorer方法

to be continued

效果

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值