>> untitled Not enough input arguments. Error in untitled (line 10) y = (n - k) >= 0;

2 views (last 30 days)
function y = stepseq(n, k)
% Generates a unit step sequence u[n-k]
% n: range of sequence
% k: offset (default is 0)
if nargin < 2
k = 0;
end
y = (n - k) >= 0;
N = 20;
% Define impulse response h[n]
n = 0:N-1;
h = (0.5.^n).*(stepseq(n,2) - stepseq(n,6));
% Define input x[n]
x = 2*(stepseq(n,-5) - stepseq(n,2));
% Compute output y[n]
y = conv(x,h);
% Plot output sequence y[n]
stem(0:N-1, y(1:N))
xlabel('n')
ylabel('y[n]')
title('Output of the system')
It shows:
>> untitled
Not enough input arguments.
Error in untitled (line 10)
y = (n - k) >= 0;

Answers (1)

Cris LaPierre
Cris LaPierre on 14 Mar 2023
You need to call your function by name. Your file and your function should share the same name. So your syntax should be
stepseq(n, k)
See the funcion documentation page
  • In a function file which contains only function definitions. The name of the file must match the name of the first function in the file.
Consider going through this examplefor help understanding how to call a function.

Community Treasure Hunt

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

Start Hunting!