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

1 view (last 30 days)
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

Accepted Answer

Arnab De
Arnab De on 12 Feb 2013
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.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!