Thursday, 19 December 2013

Program for Impulse Function and Step function Generation

close all;
clear all;
clc;
n=[-5:5];
i=imp_scr(0,-5,5);
subplot(2,1,1);
stem(n,i);
xlabel('time');
ylabel('amplitude');
title('impulse function');
s=step_scr(0,-5,5);
subplot(2,1,2);
plot(n,s);
xlabel('time');
yalbel('amplitude');
title('step sequence');
%user defined functons

%for imp_scr
function[x,n]=imp_scr(no,n1,n2);
n=[n1:n2];
x=[(n-n0)==0];

%for step_scr
function[x,n]=step_scr[n0,n1,n2];
n=[n1:n2];
x=[(n-n0)>=0];


Note: the user has to type the user defined functions in a new window and save them with the exact same names of imp_scr and step_scr if the user defined functions are to work
The files are to be saved in the same directory as the original file.

No comments:

Post a Comment