Why do I receive an error "Undefined function 'cos' for input arguments of type 'int32'" in Signal Processing Toolbox 6.16 (R2011b)?

21 views (last 30 days)
I have written a function in MATLAB that uses the WINDOW function from the Signal Processing Toolbox (in this example, I call the WINDOW function with the BLACKMAN window type). Why do I receive an error?
Reproduction steps:
N = int32(2048);
awin = window(@blackman,N)
Resulting error message:
Undefined function 'cos' for input arguments of type 'int32'.
Error in gencoswin>calc_window (line 90)
w = 0.42 - 0.5*cos(2*pi*x) + 0.08*cos(4*pi*x);
Error in gencoswin>sym_window (line 59)
w = calc_window(half,n,window);
Error in gencoswin (line 46)
w = sym_window(n,window);
Error in blackman (line 17)
[w,msg,msgobj] = gencoswin('blackman',varargin{:});
Error in window (line 54)
w = feval(wname,N,varargin{:});

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 23 Apr 2012
Workaround:
Recast the "N" parameter of WINDOW as a DOUBLE before calling the WINDOW function. Here is an example:
N = double(N);
awin = window(@blackman,N);
Explanation:
The MATLAB function WINDOW has a parameter N that specifies the length of the generated window. This parameter must be of type "double" because it is later used in the COS function, which cannot operate on "integer" data types.

More Answers (0)

Products


Release

R2011b

Community Treasure Hunt

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

Start Hunting!