Using coder.extrinsic with "spectrum.periodogram" in simulink?

조회 수: 1 (최근 30일)
Will Forfang
Will Forfang 2013년 2월 9일
I am trying to incorporate a matlab function into a simulink model; I've pasted the function into a "Matlab function" simulink block, but it won't run due to various functions not being supported for standalone code generation.
Here's the start of the function:
function [found, m] = FFTscan( signal, Fs )
Hs=spectrum.periodogram;
PSD=psd(Hs,signal,'Fs',Fs); %creates FFT of signal
psd(Hs,signal,'Fs',Fs)
released=PSD.Data; %strips values from FFT
PSDn=released./max(released); %normalizes values from FFT
...
Returns the following error:
The function 'spectrum' is not supported for standalone code generation. See the documentation for coder.extrinsic to learn how you can use this function in simulation.
Function 'Subsystem1/Algorithm/MATLAB Function' (#22.166.174), line 7, column 4:
"spectrum"
Launch diagnostic report.
I've tried appending the above code with:
coder.extrinsic('spectrum', 'psd');
But the block still throws the same error. Does anyone know how I can go about using these functions in simulink?
Thanks,
-Will

채택된 답변

Arnab De
Arnab De 2013년 2월 12일
From your code, it appears that spectrum is not a function, but a class. coder.extrinsic declaration does not work with classes. You need to wrap uses of that class in a function and declare that function extrinsic.

추가 답변 (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