Thursday 21 August 2014

Generate the basic elementary signals in matlab like unit step,unit ramp,unit impulse and exponential.


%program for unit step
n=input ('Enter the length of the step sequence N=')% Get the length of the require sequence from the user
t=0:n-1; % defines the time axis
y=ones(1,n)% defines an 1 x n matrix which is filled with ones
subplot(3,2,1)
stem(t,y) %displays the data as lines
ylabel ('Amplitude');% name the Y axis
xlabel ('Time Index');%Name the x axis
title ('Unit Step Signal by 1311977'); % Giving the title for the plot
%program to generate Impulse Signal
t=-2:2
y=zeros(1,5)
y(1,3)=1
subplot(3,2,2)
stem(t,y)
ylabel ('Amplitude')
xlabel ('Time Index')
title ('Impulse Signal by 1311977')
% Program to generate a ramp signal

n=input('Enter the length of ramp sequence N = ') % Get the length
s=input(' Enter the slop of the ramp S = ') % Get the slop of the ramp
t=0:n-1;
subplot(3,2,3)
stem(t,s*t)
ylabel ('Amplitude')
xlabel ('Time Index')
title('Ramp signal by 1311977')
%Program to generate the exponential sequence scaling factor less than 1


n=input('Enter the duration of the signal N = ')
a=input ('Enter the scaling factor a = ')
t=0:.1:n-1
y=exp(a*t)
subplot(3,2,4)
stem(t,y)
ylabel ('Amplitude')
xlabel ('Time Index')
title('Exponential Signal by 1311977')
%Program to generate the exponential sequence scaling factor greater than 1
n=input('Enter the duration of the signal N = ')
a=input ('Enter the scaling factor a = ')
t=0:.1:n-1
y=exp(a*t)
subplot(3,2,5)
stem(t,y)
ylabel ('Amplitude')
xlabel ('Time Index')
title('Exponential Signal by 1311977')



n=input('Enter the duration of the signal N = ')
a=input ('Enter the scaling factor a = ')
t=0:.1:n-1
y=exp(a*t)
subplot(3,2,5)
stem(t,y)
ylabel ('Amplitude')
xlabel ('Time Index')
title('Exponential Signal by 1311977')

No comments:

Post a Comment