NOW, my question is: I want to update the parameter P in simulink.
Or, I need to transmit external real-time variables into the model, and support code generation.
for example, I want change P like change y_ref_e .
This is obviously not enough information to reproduce what you are reporting.
In general, if you change the model and are rebuilding the S function, make sure you delete the folders c_generated_code and build and rerun the whole generation process.
@FreyJo
In general, if you change the model and are rebuilding the S function, make sure you delete the folders c_generated_code and build and rerun the whole generation process.
Great that you fixed your previous issue with code generation and parameters!
Just for completeness: Most likely setting sym_p at the acados ocp model was not done properly.
What you posted now is again completely different issue.
Code generation with external cost functions works fine for me.
Please open a new topic and try to explain your issue such that it can be reproduced.