- 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.
>> untitled Not enough input arguments. Error in untitled (line 10) y = (n - k) >= 0;
1 view (last 30 days)
Show older comments
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;
0 Comments
Answers (1)
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)
0 Comments
See Also
Categories
Find more on Calculus 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!