How to get a return value from a function_handle, when the function_handle is an input to a system object
이전 댓글 표시
I am using the Sensor Fusion toolbox. When I create the trackerGNN system object, I set the property 'FilterInitializationFcn' which specifies the filter initialization function. I am using the IMM filter (@initekfimm), so I would like to plot the probability of each model over time, which is the ModelProbabilities property of the IMM filter.
I want @initekfimm to output ModelProbabilities. ModelProbabilities is a property of trackingIMM, which is called from initekfimm.
My plan was to use get(IMM, ‘ModelProbabilities’) and then have initekfimm output ModelProbabilities.
The issue is that the function initekfimm is called from trackerGNN , and trackerGNN can’t output stuff that isn’t listed as one of its properties.
Here is my code:
tracker = trackerGNN( 'FilterInitializationFcn',@initekfimm,...
I want initekfimm to output ModelProbabilities whenever the filter is called. How do I access the outputs of initekfimm?
댓글 수: 4
dpb
2019년 8월 12일
Probably you'll have to wrap initekfimm in another function that can receive the desired outputs and have it put them into some variable accessible from the rest of the code. Then, of course, you use the handle of your wrapper function instead.
Mia Levy
2019년 8월 12일
dpb
2019년 8월 12일
- Yes
- Several ways. global is the crudest and only to be relied upon for the simplest of cases or as a temporary hack to test an idea. assignin is another as is scoping functions as internal such that variables share scope.
The ideas are explained in the scope of optimization or other solvers that pass function handles but same ways to share data work for other purposes, too. Paramterize Function
Mia Levy
2019년 8월 12일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Multi-Object Trackers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!