Too many input arguments ?

조회 수: 1 (최근 30일)
Christopher Piland
Christopher Piland 2019년 8월 5일
댓글: Walter Roberson 2019년 8월 5일
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]);

답변 (2개)

Basil C.
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'

Christopher Piland
Christopher Piland 2019년 8월 5일
Sorry my question was incomplete. "Fplot" is aouther function as well. It is posted bellow.
function fplot(b,a)
w = linspace(0,2,512);
F = fft(b,512)./(fft(a,512)+eps);
subplot(2,1,1)
plot(w,abs(F))
subplot(2,1,2)
plot(w,angle(F)/pi)
xlim([0,1])
  댓글 수: 1
Walter Roberson
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 CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by