Embedded Coder / Simulink & Stateflow : how to force inputs to be passed by reference?

조회 수: 8 (최근 30일)
Is there way to reuse the same memory location of the input for the outputs - essentially passed by reference? The use case I have is, a structure containing several parameter and flags are passed into a stateflow block then after processing, the some flags in the same structure is modified then outputted to the next blocks, then consequent blocks do similar things and passes the next and so on.
In the generated code, the input structure is copied to a local variable, then the new instance of structure is passed out to the next block. Due to the efficiency reason, I would like to avoid creating the local copies.
One workaround I tried is to use DataStoreMemory and set it as global variable, but the deficiency comes from the fact that when multiple block tries to access the variable, execution order is not guaranteed unless I set the block priorities. This approach sort of works but is not preferred due to the readability reason (want to have a signal line going from one block to next).
Do anyone have any suggestions on how to achieve this efficiently without relying on the DataStoreMemory?

채택된 답변

Vaibhav Awale
Vaibhav Awale 2016년 5월 6일
Hi Tim,
Using "Reusable" custom storage class might help in this case. Please refer to following documentation pages:
This might help you in achieving what you want.
Hope this helps.
Regards,
Vaibhav
  댓글 수: 2
Tim Shin
Tim Shin 2016년 5월 6일
Vaibhav, Thank you for the reply.
It is almost what I want to achieve, but currently reuse storage class is restricted to a pair of signal lines. In the case of multiple cascaded blocks, I am not able to make it reuse same variables - keeps creating copies.
Heidi Zaiter
Heidi Zaiter 2020년 3월 3일
Yeah it doesn't work at all, it seems like a limitation of MATLAB / Embedded coder.
Even in 2020...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Embedded Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by