Passing data by reference to Matlab toolbox functions for code generation

7 ビュー (過去 30 日間)
Jakub Jon
Jakub Jon 2021 年 10 月 14 日
回答済み: Harsh 2025 年 1 月 30 日 11:36
Hello everyone.
I am working on optimization of generated code. My algorithm uses toolbox function interp1 for linear interpolation. Code for it is generated by Matlab embedded coder. I want to prevent copying of input arrays to it. Normally function doesn't define input argument as in/out, but algorithm doesn't use them afterwards and copy is redundant. Is there a way to tell Matlab coder about it to do optimization.

回答 (1 件)

Harsh
Harsh 2025 年 1 月 30 日 11:36
Hi Jakub,
You can use the same variable as both an input and an output. This avoids the parameter being passed by value in the generated code. For more information regarding this practice please check the following documentation - https://www.mathworks.com/help/coder/ug/eliminate-redundant-copies-of-function-inputs.html

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by