MATLAB Answers

Combining two C++ generated codes from 2 Simulink model

3 views (last 30 days)
Trinh Nguyen Cong
Trinh Nguyen Cong on 20 Mar 2017
Edited: Trinh Nguyen Cong on 20 Mar 2017
I have 2 Simulink models, one is a spring-mass-damper system:
and one is a PI controller
with parameters: m = 1;c = 10;k = 50;Kp = 30;Ki = 70; reference = 0.2; After generating C++ codes using Simulink Coder for these 2 models, I tried to include both C++ files in one main class which simply run C++ code of the controller first and then the plant model. The results are quite different with the Simulink even though it converses to 0.2 eventually. I tried to connect them both in Simulink and then generate 1 C++ file, then run this file but the result is also different from Simulink file and from the combination of 2 generated codes. Could anyone give me a suggestion on how this happens? Thank you very much in advance!

  0 Comments

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!