code generation with do not using temp local variable

I try to use multy operation sentence in stateflow.
And I generate this code, it makes temp variable.
example of sentence is ' input = KTH / HJY * JSM ' .
And it brings
rtb_Gain1_h = KTH / HJY; ( rtb_Gain1_h is autmatically generated Local variable )
input = rtb_Gain1_h * JSM;
I want to use this sentence in once like ' input = KTH / HJY * JSM '
I tried to change optimize setting not to 'Enable local block ouputs' it works but other code are affectted to be bad readabillity.
Isn't no way to remove any of not intended local variable?
Thank you.

 채택된 답변

Nick Sarnie
Nick Sarnie 2019년 6월 5일
편집: Nick Sarnie 2019년 6월 5일

0 개 추천

Hi TaeHee,
It is unlikely that you will be able to control the optimization to this level of detail. If you prefer the temporary variable to be removed, please 'Enable local block outputs' option. There is often a tradeoff between performance and readability in many areas of computing.
Thanks,
Nick

댓글 수: 2

I really appreciate your answer. Nick.
I tried your solution. and it generate without local variable.
But now it generate so many global variable to represent mid-process of operation.
It seems just using global variable instead local variable and readability is so bad.
I hope to just touch only that part.
Thanks for your answer.
TaeHee Kwun
Hi TaeHee,
If global variables are your concern, you can tell the code generator to try to avoid them. Please see the below doc link:
Thanks,
Nick

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

추가 답변 (0개)

카테고리

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

제품

릴리스

R2019a

질문:

2019년 6월 4일

댓글:

2019년 6월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by