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

1 次查看(过去 30 天)
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