MATLAB Answers


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

Asked by Alexander Dingwall on 13 May 2019
Latest activity Commented on by Alexander Dingwall on 13 May 2019
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.


Sign in to comment.

1 Answer

Answer by Fangjun Jiang on 13 May 2019

  1 Comment

This example isn't the same as what I want.
I can't upload my model and C code if you want?

Sign in to comment.