Skip to content

Instantly share code, notes, and snippets.

@MichaelTr7
Created April 14, 2021 17:14
Show Gist options
  • Save MichaelTr7/f76dab44c02f8b9ba2254805ab0b1def to your computer and use it in GitHub Desktop.
Save MichaelTr7/f76dab44c02f8b9ba2254805ab0b1def to your computer and use it in GitHub Desktop.
A MATLAB script that defines a function in terms of the basic unit step.
%% FUNDAMENTAL UNIT STEP FUNCTION %%
%Subplot dimensions%
Rows = 3;
Columns = 1;
u = @(n) (n >= 0);
subplot(Rows,Columns,1); fplot(u);
title("Unit Step Function");
xlim([-5 5]);
ylim([-0.1 1.1]);
%% FUNCTION CHARACTERIZED IN TERMS OF UNIT STEPS %%
Function = @(n) u(n) - u(n-4);
subplot(Rows,Columns,2); fplot(Function);
title("Function Characterized in Terms of Unit Steps");
xlim([-5 5]);
ylim([-0.1 1.1]);
%% DISCRETE PLOT OF ABOVE FUNCTION %%
N = (0:5);
subplot(Rows,Columns,3); stem(Function(N));
title("Discrete Plot of Above Function");
xlim([-5 5]);
ylim([-0.1 1.1]);
@MichaelTr7
Copy link
Author

MichaelTr7 commented Apr 14, 2021

Output Result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment