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

32 次查看(过去 30 天)
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{:});

采纳的回答

MathWorks Support Team
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.

更多回答(0 个)

产品


版本

R2011b

Community Treasure Hunt

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

Start Hunting!

Translated by