Is there a way to pass tables as a parameter to a Simulink "Matlab Function" block?

7 ビュー (過去 30 日間)
Andy
Andy 2015 年 10 月 21 日
コメント済み: Andy 2015 年 10 月 22 日
Not sure how much the question needs leaboration. I Have a native Matlab function working, and now need to make a Simulink block out of it. I'm really strugglink with both how to define the type, and pass the actual table name. Thanks for your help.

採用された回答

Sebastian Castro
Sebastian Castro 2015 年 10 月 22 日
The MATLAB Function block operates by generating code from the MATLAB code inside it, so the syntax is somewhat restricted.
I just did a quick search of the MATLAB Language features supported for code generation, and tables, being a new data type, are not yet supported.
Your solutions would be:
  1. Refactor your code so it doesn't use tables
  2. Tell MATLAB to use the interpreter (and not code generation) to run your function. This will be acceptable only if you don't plan on running your model outside the MATLAB environment, i.e., you're won't be generating code from the whole model.
For the second option, you could
  • Call the whole function using an "Interpreted MATLAB Function" block, or
  • Put all the table-related code in a separate "helper" function and force this function to be run by the MATLAB interpreter by using coder.extrinsic.
- Sebastian
  1 件のコメント
Andy
Andy 2015 年 10 月 22 日
Thanks for the response. While the second answer sounds interesting, I do plan to make production code to run outside of Matlab, but might look into when I have time.
I ended up with a slightly clungy solution, but it works as the the table is not that huge. I turned the table into a structure with each row name being a unique field, and each field is used only once. As Matlab function blocks handle structure parameters, I can then find the fieldname{1} value in the code.

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

その他の回答 (0 件)

カテゴリ

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