How do I generate code that does not copy read-only data accessed in a MATLAB Function block?

I have a MATLAB Function Block in a Simulink model that reads from a large amount of data. I would like to make sure that only one copy of this data exists in the generated code, to avoid unnecessary time and memory overhead.

How do I give the MATLAB Function Block access to this data without ever making a copy of it?

 채택된 답변

For this application, you should use a "Simulink.Parameter". Create one in your workspace, and store your desired data into the Simulink Parameter's "Value". Then, in your MATLAB Function block, in the Symbols pane, add a new symbol of type "Parameter Data", with the same name as the Simulink Parameter you created. You can then access the parameter as if it was a function argument.
 
>> mySlParam = Simulink.Parameter;
>> mySlParam.Value = 5;

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품

릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by