Too many input arguments ?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Basil C.
2019년 8월 5일
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
Christopher Piland
2019년 8월 5일
댓글 수: 1
Walter Roberson
2019년 8월 5일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!