Simscape run-time parameter in code generation

조회 수: 2 (최근 30일)
Ramkumar Natarajan
Ramkumar Natarajan 2020년 10월 22일
댓글: Ramkumar Natarajan 2020년 10월 23일
Below is a simple Simscape model of a pendulum. I generated reusable C++ code using Simulink Coder (grt_rtw) and it works fine. But I could not locate or generate a run-time paramter to be available for tuning in the generated code, details below:
I have set the State Targets > Specify Position Target > Value as a run-time parameter (see below) and have set the Configuration Parameters > Code Generation > Optimization > Default parameter behavior to be Tunable and configured the run-time parameter variable as ExportedGlobal.
My problem is I still could not locate this run-time parameter variable in the generated code. I want to be able to change the value of this parameter in the generated code without regenerating the code again. How can I get this parameter in the generated code and where will it be in the generated code (which file and data structure)?
Thanks. Any help is appreciated!

채택된 답변

Juan Sagarduy
Juan Sagarduy 2020년 10월 23일
Hi Ramkumar
It should be visible in the Interface parameter in the generated code. Publish the report and the parameter shall appear. Remember that run-time for structured Simscape parameters is only supported from 2020a.
Best Regards Juan (MathWorks)
  댓글 수: 1
Ramkumar Natarajan
Ramkumar Natarajan 2020년 10월 23일
Hi Juan, Thanks for the answer. I was able to get the parameter accessible in the generated code by using the latest version 2020b. However, it not mentioned anywhere in the documentation that struct variables for Simscape parameters are not supported in "code generation". The problem is struct variables work completely fine within Simscape in the Matlab environment (before code generation) even in 2019b version. However it fails silently without any warning or error when code generation is used and the struct variable doesn't appear in the generated code.
I can see in the Release notes (https://www.mathworks.com/help/physmod/simscape/release-notes.html?) that struct variables for run-time parameters are supported from 2020a. But like I said within Matlab/Simulink struct variables work for run-time parameters even in 2019b but doesn't work for code generation.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Run-Time Parameters에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by