persistent variable simulink codegen stateflow error: "IR Construction failed"

조회 수: 10 (최근 30일)
John Hatrick
John Hatrick 2019년 5월 7일
답변: Fangjun Jiang 2019년 5월 8일
Greetings,
I'd like to include a function similar to the following in my codegen-compiled simulink model:
function u = PD_control( x )
persistent x_last_iter % save last x each iter
if isempty(x_last_iter)
x_last_iter = x; % 1st iter -> set to 1st x
end
Kp = 1; Kd = 1; % PD control params
u = -x*Kp + (x_last_iter - x)*Kd % calculate control input
end
However, I get compiler error below. "IR Construction failed" returns zero hits when I search the web.
I can avoid this error by setting the initial value to 0 instead: "x_last_iter = 0;" But this is not ideal.
Anyone understand this error? I feel I am correctly following the documentation here: Persistent Variables and Persistent Array Variables
Respectfully, John

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2019년 5월 8일
I think IR means "Internal Representation". It might be a bug. Make a simple example and submit a service request to the Mathworks.

카테고리

Help CenterFile Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by