How to reference an m-file from a MATLAB Function block instead of embedding code in block?
1 回表示 (過去 30 日間)
古いコメントを表示
In Simulink, I'd like to make my MATLAB Function blocks more transparent to my version control system, git. If code inside the block changes, I want it to be very apparent in the git diff of an m-file. Without this, code changes in the block are hidden in the indecipherable diff of the containing Simulink model file.
Ideally, I could set up a MATLAB Function block to reference an m-file (*.m) instead of embedding the code in the block. Is this possible? How?
0 件のコメント
回答 (1 件)
Walter Roberson
2020 年 11 月 13 日
If I recall correctly, it is not directly possible with .mlx files, but it was possible with .slx files by hacking the data structures (not something that methods were provided for.)
The work-around is to have the function block code be pretty much dummy code that mostly just calls the function by name. There is a possibility that you might need to put in the typing information, so it might not be quite as straight forward as
[out1, out2, out3] = MyFunction(in1, in2)
you might possibly need to initialize the datatypes and sizes of the outputs before making the call.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Programmatic Model Editing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!