How to generate c code of dsp.MedianFilter?

조회 수: 1 (최근 30일)
Chase Bowman
Chase Bowman 2021년 9월 23일
답변: Ezra Stein 2021년 9월 23일
I am attempting to generate code from dsp.MedianFilter. I believe I may not be abiding by the limitations stated here: https://www.mathworks.com/help/coder/ug/use-system-objects-in-matlab-code-generation.html
However, I am sure what is wrong exactly. When I attempt to generate code, I get:
"Error determining type for input 'movMed: medObject' ".
"Class dsp.MedianFilter is not supported by coder.Type as it is a handle class."
Am I setuping this up correctly? Thanks.
testbench.m
t = 1:1:12;
medObject = dsp.MedianFilter('WindowLength',4);
for i = 1:12
fil(i) = movMed(i, medObject); %
end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
movMed.m
function f = movMed(t, medObject)
f = medObject(t);
end

답변 (1개)

Ezra Stein
Ezra Stein 2021년 9월 23일
Hi Chase,
There is currently a limitation in MATLAB Coder which prevents using handle classes as top-level entry-point arguments (inputs or outputs to entry point functions). For details, please see the link below:
In your case, dsp.MedianFilter is a handle class object so it cannot be used as an argument to the entry point function 'movMed'. The error you are observing regarding 'coder.Type' is a consequence of attempting to specify a handle class as an argument to an entry point function.
As a possible workaround, you can move the creation of the 'dsp.MedianFilter' object inside of the entry point so that it is no longer needed as an argument:
function f = movMed(t)
medObject = dsp.MedianFilter('WindowLength', 4);
f = medObject(t);
end
>> codegen movMed -args 0
MATLAB Coder is still capable of generating code for handle class objects as long as those objects do not escape the generated code via the inputs or outputs of the entry points.

카테고리

Help CenterFile Exchange에서 Signal Generation에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by