How do I link extern variables and stateflow input when using custom c code?

조회 수: 2 (최근 30일)
I am trying to use a custom C code function in my stateflow chart. The C file looks like
extern float A1;
extern float A2;
extern float A3;
float do_something(void) {
return cos(A1)*sin(A2)*cos(A3);
}
I also have three stateflow inputs of the same name? When I run the simulink model, I get undefined reference errors for A1, A2 and A3. How can link the inputs with the extern variables so that the inputs to the stateflow chart can be used in the C code function?
Also please don't tell me to do:
float do_something(float A1, float A2, float A3) {
return cos(A1)*sin(A2)*cos(A3);
}
Since, I know that this works. I need the inputs to be assigned to the extern variables.
Thanks

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2019년 5월 13일
  댓글 수: 1
Alexander Dingwall
Alexander Dingwall 2019년 5월 13일
This example isn't the same as what I want.
I can't upload my model and C code if you want?

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

카테고리

Help CenterFile Exchange에서 Complex Logic에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by