フィルターのクリア

How to set (check?) the 'inport' datatype for a 'Matlab system block' to a simulink.bus

5 ビュー (過去 30 日間)
Ludo Houben
Ludo Houben 2023 年 10 月 9 日
コメント済み: Ludo Houben 2023 年 10 月 19 日
Hi All
When I create a subsystem, then I can set a fixed datatype "Bus: <busname>" for an 'inport'
How to do this for a 'matlab.System' block?
classdef myClass < matlab.System
methods (Access = protected)
function out = stepImpl(obj, i_Add, i_stPAR)
arguments(Input)
obj;
i_Add uint16 = 1;
i_stPAR Bus:'ST_PAR'; % <=== This part!!??, how to validate if the correct simulink.bus is connected?
out = i_stPAR.var1 * i_stPAR.var2 + i_Add;
end
end
end

回答 (1 件)

SAI SRUJAN
SAI SRUJAN 2023 年 10 月 19 日
Hi Ludo Houben,
I understand that you are trying to verify the appropriate connection of simulink.bus within a matlab.system block.
To verify the connection check the properties of the expected Simulink.Bus Element, such as its Name, dimensions, or datatype with the correct Simulink.Bus. In MATLAB, you can utilize the "get_param" function to effectively address this matter.
You can follow below given example to resolve the issue,
% Provide the actual block path
% You can get the block path using find_system.
blockPath = 'path_to_the_block';
% 'Parameter' can be Name, DataType or Dimensions
% Mention the parameter you want to validate
connectedBus = get_param(blockPath, 'Parameter');
% check if the connectedBus and expectedBus are equal - isequal
You can refer to the following documentation to understand more about "get_param" and "find_system" functions in MATLAB.
  1 件のコメント
Ludo Houben
Ludo Houben 2023 年 10 月 19 日
Hi Sai Srujan
Thank you for your reply, but I'm not trying to verify, but I am trying to 'force' the input to be from a specific simulink.bus type. I'm using value's from the struct internally and if there is nothing connected, then still the class should work.
Currently it is generating errors as it is being interpreted as a 'double' instead of the required 'Bus: <bus type>'. So at compile time, even if nothing is connected, then the class should still know that the input is of this specific type.
Regards
Ludo

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeComposite Interfaces についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by