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]);

Réponses (2)

Basil C.
Basil C. le 5 Août 2019

0 votes

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 le 5 Août 2019

0 votes

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 commentaire

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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by