Too many input arguments for function not called in live script

1 view (last 30 days)
Hello
I am trying to use a windowing function and I am using a live script. I have the various window function handles as a drop down and I am generating windows based on the drop down value.
% Various Orders of FIR
min_ord = 3; % This is a slider
max_ord = 5; % This is a slider
cutoff = 75; % This is a slider
options = [];
windowf = @chebwin; %This is a drop down
% These three windows require an input
if isequal(windowf, @kaiser)
options = 0.5; % Beta value
elseif isequal(windowf, @chebwin)
options = 50; % Sideband Attenuation in dB
elseif isequal(windowf, @tukeywin)
options = 0.44; % Ratio of taper to constant section
end
h_arr = []; wh_arr = [];
out_arr = [];
gp_arr = []; wgp_arr = [];
for i = min_ord:1:max_ord
windowvals = [];
if isempty(options)
windowvals = window(windowf, i+1)
else
windowvals = window(windowf, i+1, options);
end
b = fir1(i, cutoff/(fs/2), "low", windowvals);
...
Now when I run this code, I am getting the following error
Error using barthannwin (line 24)
Too many input arguments.
This happens even if the selected window is not Bartlett-Hann. I have even tried to remove Bartlett-Hann from the drop down options and I am still gettting the same error. I am not sure how to fix this. Is there a workaround?

Answers (1)

Mahesh Taparia
Mahesh Taparia on 22 Feb 2021
Hi
I replicate your code, its working in my case. You have not defined the variable fs, also did not put end after for loop. For your 2nd query, try to clear the variable and again run the code. It will work.
Hope it will help!

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!