How to make a bus object?
6 ビュー (過去 30 日間)
古いコメントを表示
I have a library that I want to feed a bus into. I think I need to change my inport to a bus data type so that it knows what to expect in terms of signal names. However, when I select Bus: <object name>, I don't have an object name to give it. I'm assuming I need to have a .m file somewhere in the workspace with a bus data type that I created? How do I do this? Thanks
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1450607/image.png)
0 件のコメント
回答 (1 件)
Daniel Bengtson
2023 年 8 月 4 日
Something like this should work.
function create_Buses()
% Bus object
clear elems;
elems(1) = Simulink.BusElement;
elems(1).Name = 'BusSig_1';
elems(1).Dimensions = 1;
elems(1).DimensionsMode = 'Fixed';
elems(1).DataType = 'uint32';
elems(1).SampleTime = -1;
elems(1).Complexity = 'real';
elems(1).Min = [];
elems(1).Max = [];
elems(1).DocUnits = '';
elems(1).Description = '';
elems(2) = Simulink.BusElement;
elems(2).Name = 'BusSig_2';
elems(2).Dimensions = 1;
elems(2).DimensionsMode = 'Fixed';
elems(2).DataType = 'uint32';
elems(2).SampleTime = -1;
elems(2).Complexity = 'real';
elems(2).Min = [];
elems(2).Max = [];
elems(2).DocUnits = '';
elems(2).Description = '';
elems(3) = Simulink.BusElement;
elems(3).Name = 'BusSig_3';
elems(3).Dimensions = 1;
elems(3).DimensionsMode = 'Fixed';
elems(3).DataType = 'uint8';
elems(3).SampleTime = -1;
elems(3).Complexity = 'real';
elems(3).Min = [];
elems(3).Max = [];
elems(3).DocUnits = '';
elems(3).Description = '';
BusData = Simulink.Bus;
BusData.HeaderFile = '';
BusData.Description = '';
BusData.DataScope = 'Auto';
BusData.Alignment = -1;
BusData.Elements = elems;
clear elems;
assignin('base','BusData', BusData);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Composite Interfaces についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!