フィルターのクリア

Return structure from setExternalInputsFcn

3 ビュー (過去 30 日間)
William Stokes
William Stokes 2022 年 3 月 15 日
コメント済み: Alvaro 2023 年 1 月 18 日
I am using simulink.compiler.setExternalInputsFcn to declare a callback function which returns a value to each input port at each timestep.
Something like
simin = similink.compiler.setExternalInputsFcn(simin, inputsFcn)
If the return value from this function is scalar, or an array this seems to work fine. However, I want to return a structure, which will be mapped to a bus in Simulink.
I create the bus type in my model data dictionary, and set it as the type for the input port. I declare the callback like so
function v = inputsFcn(id, t)
v = struct('a',1,'b',2,'c',3);
end
But trying to run this gives the following line in the error...
ExternalInputsFcn could not be enabled due to the following incompatibilities:
and further down...
Caused by:
Error using Simulink.Simulation.internal.DesktopSimHelper
The data type of root inport 1 is not of a supported type.
Is this not allowed???
  1 件のコメント
Alvaro
Alvaro 2023 年 1 月 18 日
Could you elaborate as to why you are trying to pass a struct into your inport?
I couldn't get simulink.compiler.setExternalInputsFcn to take a struct either but I am getting this error
The dimensions, data type or complexity of the return value from the ExternalInputsFcn for port 1 are incorrect.
Perhaps converting the struct to an array would work for you?

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by