How to save classes in matlab in persistent variables during code generation

If objects are stored in persistent variables, initialize System objects once by embedding the object handles in an if statement with a call to isempty().
How to implement this sentence
function PFesti()
if(isempty(pf@stateEstimatorPF))
pf = stateEstimatorPF;
else
pf.predict();
end
end
I wrote these codes above but it doesn't work, does anyone know how matlab's classes are initialized only once after the embedded code is generated?

 채택된 답변

function PFesti()
persistent pf
if isempty(pf)
pf = stateEstimatorPF;
end
pf.predict();
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2022년 2월 2일

댓글:

2022년 2월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by