Too many input arguments ?
1 view (last 30 days)
Show older comments
I have the following m script that is going to ask a function in anuther m script. For some reason fixplot is being given too many input arguments and I don't know why.
Her is the code for the main function that will be calling the other function.
function lab5
% lab5.m
% You will provide the print-out for the following
clear all;
clc;
% A (non-causal) bandstop filter
figure
fizplot([1 2 2], [0 1 .8]);
title('A (non-causal) bandstop filter');
/// And her is the function it is trying to call and place its input through.
function fizplot(b, a)
clf;
b = b(:)';
a = a(:)';
fplot(b, a, 'XLim', [0 1], 'XTick', 0.25);
h = get(gcf, 'Children');
for i = 1:2
set(h(i), 'Units', 'normalized');
pos = get(h(i), 'Position');
pos(3) = 0.33;
set(h(i), 'Position', pos);
end
subplot(2, 2, 2);
zplot(b, a);
title(['H(z)=' bastrnew({b, a}, 1)]);
subplot(2, 2, 4);
iplot(b, a);
figure(gcf);
return
/// And this is the error message i keep getting every time I run the code.
Error using fplot
Too many input arguments.
Error in fizplot (line 15)
fplot(b, a, 'XLim', [0 1], 'XTick', 0.25);
Error in Lab5 (line 8)
fizplot([1 2 2], [0 1 .8]);
0 Comments
Answers (2)
Basil C.
on 5 Aug 2019
The function fplot is used to plot functions. The input that you are providing are array elements so you could rather use
plot(b,a);
Also the function fplot does not take the limits of the functions (y=f(x)) as an argument, it can only take the limits to 'x'
0 Comments
Christopher Piland
on 5 Aug 2019
1 Comment
Walter Roberson
on 5 Aug 2019
You have
function fplot(b, a)
That accepts only two arguments
fplot(b, a, 'XLim', [0 1], 'XTick', 0.25);
Tries to call fplot with 6 arguments.
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!