A top-level output parameter containing a class is not supported in MATLAB Function Block. Output parameter 'mes' contains a class.

14 ビュー (過去 30 日間)
Bhavik
Bhavik 2023 年 3 月 9 日
回答済み: Tejas 2024 年 11 月 11 日 6:12
A top-level output parameter containing a class is not supported in MATLAB Function Block. Output parameter 'mes' contains a class.

回答 (1 件)

Tejas
Tejas 2024 年 11 月 11 日 6:12
Hello Bhavik,
The issue mentioned above occurs because a class is not a supported data type for the output port of a 'MATLAB Function' Block. For details on supported data types for the output port, refer to this documentation: https://www.mathworks.com/help/simulink/slref/matlabfunction.html.
Assuming the properties of the 'objectDetection' class are of a data type supported by the 'MATLAB Function' Block output port, try this workaround to resolve the issue:
  • Extract the values of the properties from the 'objectDetection' class and store them in a vector.
  • Pass this vector as the output of the 'MATLAB Function' Block.
Here is an example code snippet:
function mes = my_func(time, color)
detection = objectDetection(time, color);
mes = [detection.Time detection.Color detection.Measurement];
end

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by