필터 지우기
필터 지우기

Fixed 'simulink.bus' for property declaration

조회 수: 3 (최근 30일)
Ludo Houben
Ludo Houben 2023년 7월 26일
답변: Ludo Houben 2023년 8월 23일
Hi All
I'm trying to create my first class and I'm struggeling to define my property as a fixed 'simulink.bus' type. I created a simulink.bus (struct) 'ST_DATARECORD' with (at this moment) 2 variables. I want to use this bus to define the internal property.
classdef myFunct < matlab.System
properties (Access = public)
bCmdAddDataPrevScan uint8 = 0
arrstDataBuffer ST_DATARECORD % Buffer holding the supplied data
nWriteIndex uint16 = 0
end
function obj = mAddData(obj,i_Input)
obj.arrstDataBuffer.variable1 = i_Input; % Copy input data to buffer location
end
end
How to create this? The simulink.bus definition is available in my workspace. The supplied code above is only an example (pseudo) code, so I can understand what to do. Thanks for any anser.
Regards
Ludo
  댓글 수: 1
Ludo Houben
Ludo Houben 2023년 8월 23일
I found an example for a declaration here, but this only displays the default 'double'. How to change this to a 'simulink.bus' type??
classdef ValidationExample
properties
MyPublicData (1,:) double {mustBePositive} = [1 1 1]
end
end

댓글을 달려면 로그인하십시오.

채택된 답변

Ludo Houben
Ludo Houben 2023년 8월 23일
Finally got it to work :-)
The array has now a fixed size of 2 records of the datatype ST_DATARECORD
classdef myFunct < matlab.System
properties (Access = public)
bCmdAddDataPrevScan uint8 = 0
arrstDataBuffer(:,2) = Simulink.Bus.createMATLABStruct('ST_DATARECORD') % Buffer holding the supplied data
nWriteIndex uint16 = 0
end
function obj = mAddData(obj,i_Input)
obj.arrstDataBuffer.variable1 = i_Input; % Copy input data to buffer location
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Create System Objects에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by