embedded matlab function error
Show older comments
Hello everyone,
i used in may simulink model the Embedded MATLAB Function. Embedded MATLAB Function occurs error when it is running and error message is
"Function output 'x' cannot be of MATLAB type.
Function 'Embedded MATLAB Function' (#748.0.2126), line 1, column 1:
"function x =melbankmm(p,n,fs,fl,fh)"
Matlab version is v7.8.0(R2009a)
code is following:
*****************************************************************************
function x =melbankmm(p,n,fs,fl,fh)
%MELBANKM determine matrix for a mel-spaced filterbank [X,MN,MX]=(P,N,FS,FL,FH,W)
%
% Inputs: p number of filters in filterbank
% n length of fft
% fs sample rate in Hz
% fl low end of the lowest filter as a fraction of fs (default = 0)
% fh high end of highest filter as a fraction of fs (default = 0.5)
% w any sensible combination of the following:
% 't' triangular shaped filters in mel domain (default)
% 'n' hanning shaped filters in mel domain
% 'm' hamming shaped filters in mel domain
% 'z' highest and lowest filters taper down to zero (default)
% 'y' lowest filter remains at 1 down to 0 frequency and
% highest filter remains at 1 up to nyquist freqency
% If 'ty' or 'ny' is specified, the total power in the fft is preserved.
%
% Outputs: x a sparse matrix containing the filterbank amplitudes
% If x is the only output argument then size(x)=[p,1+floor(n/2)]
% otherwise size(x)=[p,mx-mn+1]
% mn the lowest fft bin with a non-zero coefficient
% mx the highest fft bin with a non-zero coefficient
%
% To plot filterbanks e.g. plot(melbankm(20,256,8000)')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eml.extrinsic('sparse');
w='m';
f0=700/fs;
fn2=floor(n/2);
lr=log((f0+fh)/(f0+fl))/(p+1);
% convert to fft bin numbers with 0 for DC term
bl=n*((f0+fl)*exp([0 1 p p+1]*lr)-f0);
b2=ceil(bl(2));
b3=floor(bl(3));
b1=floor(bl(1))+1;
b4=min(fn2,ceil(bl(4)))-1;
pf=log((f0+(1:127)/n)/(f0+fl))/lr;
fp=floor(pf);
pm=pf-fp;
k2=b2-b1+1;
k3=b3-b1+1;
k4=b4-b1+1;
r=[fp(4:127) 1+fp(1:107)];
c=[4:127 1:107];
v=2*[1-pm(4:127) pm(1:107)];
mn=b1+1;
mx=b4+1;
v=1-0.92/1.08*cos(v*pi/2);
x=sparse(r,c+mn-1,v,p,1+fn2);
**************************************************************************
please help me
best regard
2 Comments
Walter Roberson
on 25 Jul 2012
It appears to me that embedded matlab does not support sparse. I find specific documentation for that at the time that embedded matlab was introduced, but it is not impossible it was added later. I do see at least some explicit restrictions on sparse in current documentation, such as http://www.mathworks.com/help/toolbox/simulink/slref/simulink.runtimeblock.html
latsi lab
on 25 Jul 2012
Accepted Answer
More Answers (1)
latsi lab
on 25 Jul 2012
1 Comment
Kaustubha Govind
on 26 Jul 2012
Thanks for posting your solution!
Categories
Find more on Texas Instruments C2000 Processors in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!