How to implement this c-code: if(Flag == 1) {Flag = 0;} ?

조회 수: 10 (최근 30일)
Charles Wang
Charles Wang 2011년 10월 14일
댓글: Manjunath Bhimalli 2019년 1월 14일
I used a signal (this is what I needed) for Flag at an input port of stateflow, but Flag is not recognized inside the stateflow. If I add an input data in the stateflow, it will not be allowed to change the value (through a transit with a statement {Flag=0;} inside the stateflow).
Please help. Thanks!

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 10월 14일
This is one of the difference between C and Simulink. In C, you can re-use the variable name. In Simulink, the signal name represents the data flow. You can't re-use the signal name. You have to declare an output for the Stateflow and then assign value accordingly.
  댓글 수: 12
Fangjun Jiang
Fangjun Jiang 2011년 11월 1일
You are right. Port name is used to identify the port block. The generated code will not necessarily use port name for variable name.
Manjunath Bhimalli
Manjunath Bhimalli 2019년 1월 14일
Try with connecting Unit Delay(1/z) block and take the feedback.

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

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by