How to pass cell array data type to a Simulink MATLAB function block

조회 수: 2 (최근 30일)
Hew
Hew 2019년 4월 2일
답변: Naga 2024년 10월 23일
I've tried declaring a Cell Array variable as global and registering it with a MATLAB function block in the Ports and Data Manager, and allocated a Data Store Memory block in the Simulink model but it STILL doesnt want to recognise it.
If anyone has ANY WAY of accessing a cell array type variable from inside a MATLAB function block in a Simulink model I would be most appreciative!
I've had little luck using Simulink.Signals either.

답변 (1개)

Naga
Naga 2024년 10월 23일
Hello Hew,
Passing cell array data to a MATLAB Function block in Simulink can be challenging due to data type limitations. Here are some concise strategies to address this:
  • Convert Cell Array to Struct: Transform your cell array into a struct with fields representing each cell. Use this struct as an input to the MATLAB Function block and access its fields inside the block.
  • Break down the cell array into individual elements. Pass each element separately to the MATLAB Function block.
  • Create a bus object reflecting your cell array's structure. Convert the cell array to a bus signal and pass it to the block.
  • Use an external MATLAB script to handle the cell array data.Invoke this script within the MATLAB Function block.
Ensure that your data types are compatible with the MATLAB Function block for smooth processing. Use Simulink's debugging tools to trace data flow and resolve issues. These steps will help you effectively manage cell array data in Simulink.

카테고리

Help CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by