Trim with Generated Simulink Code

조회 수: 3 (최근 30일)
Jimmy Lu
Jimmy Lu 2018년 7월 26일
편집: Jimmy Lu 2018년 7월 27일
I've used Simulink Coder to generate the C code for the grt target. The idea is to generate an executable such that MATLAB and Simulink are not needed to run the model. I've managed to create a wrapper C application to work with the generated code. But I'm having trouble performing the trimming operation. In order for the model to be useful, trimmed conditions would need to be found prior to simulation (in many cases, finding the trimmed conditions is more important than simulation).
Under MATLAB, I was able to create a Newton-Raphson trimming routine. The jacobian is obtained by running the model command to get the outputs/derivatives at t=0. The problem is that, with the generated code, I only have three exposed extern functions available to me: model_initialize, model_step, and model_terminate. model_step updates the derivatives/outputs, but it only provides the results at the end of the first time step, not at t=0.
Any suggestion as to I should tackle this?
  댓글 수: 2
TAB
TAB 2018년 7월 26일
Which Matlab version are you using ?
Jimmy Lu
Jimmy Lu 2018년 7월 26일
Matlab 2017a

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

채택된 답변

Jimmy Lu
Jimmy Lu 2018년 7월 27일
편집: Jimmy Lu 2018년 7월 27일
This is more of a hack. For a $10k product, I really think breaking the model_step method into separate evaluation and update methods is essential.
Within the rt_ertODEUpdateContinuousStates method, I bypass everything after and including the line:
local_numjac(si,x0,f0,fac,dfdx)
The state derivatives were calculated prior to this and the subsequent section is the integration scheme.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by