Thursday 21 August 2014

Write a program in matlab to compute discrete convolution of two sequences.


%Program to find the linear convolution of two sequences

x1=input('Enter the first sequence x1(n) = ')
t1=input('Enter the starting time of first sequence t1 = ')
x2=input('Enter the second sequence x2(n) = ')
t2=input('Enter the starting time of second sequence t2 = ')
l1=length(x1)
l2=length(x2)
ln=l1+l2-1

yn=conv(x1,x2)
a=t1+l1-1
t=t1:a
subplot(311)
stem(t,x1)
xlabel('time--->')
ylabel('amplitude--->')
title('First sequence by 1311977')

a=t2+l2-1
t=t2:a
subplot(312)
stem(t,x2)
xlabel('time--->')
ylabel('amplitude--->')
title('Second sequence by 1311977')
tn=t1+t2
a=tn+ln-1
t=tn:a
subplot(313)
stem(t,yn)
xlabel('time--->')
ylabel('amplitude--->')
title('Convolved output by 1311977')

%output

%Enter the first sequence x1(n) = [1 2 6 2 3 1 4]
%Enter the starting time of first sequence t1 = -3
%Enter the second sequence x2(n) = [3 1 4 5 2]
%Enter the starting time of second sequence t2 = -1

Write a program in matlab to generate standard discrete sequences like sine wave,triangular wave and square wave.


%program to generate sine wave

f= input('enter the frequency in hertz of the sine wave')
t=0:.01:5
y=sin(2*pi*f*t)
subplot(2,2,1)
stem(t,y)
ylabel ('Amplitude')
xlabel ('Time Index')
title('Sine wave by 1311977')

%Program to generate triangular waveform

n=input ('Enter the length of the sequence N= ')
t=0:.1:n
y=sawtooth(t,.5); %sawtooth with 50% duty cycle (triangular)
subplot(2,2,2)
stem(t,y)
ylabel ('Amplitude')
xlabel ('Time Index')
title('Triangular waveform by 1311977')

%Program to generate a continuous time square wave

a=input('Enter the amplitude of the square wave A = ')
f= input('Enter the frequency of the square wave F = ')
dc=input('Enter the duty cycle of the wave DC = ')
f=f*2*pi
t=0:.01:1
y=a*square(f*t,dc)
subplot(2,2,3)
stem(t,y)
ylabel ('Amplitude')
xlabel ('Time Index')
title('square waveform by 1311977')

Write a Program to develop program module based on operatios on sequences like signal folding and signal shifting.


Code:
n=0:3
x=input('Enter Input Signal:')
%Input Signal
subplot(2,2,1)
stem(n,x)
xlabel('n-->')
ylabel('x(n)-->')
title('Input Signal:')
%Folded Signal
subplot(2,2,2)
n1=-n
stem(n1,x)
xlabel('n-->')
ylabel('x(n)-->')
title('Folded Signal:')
%Shifted Signal
N=length(x)
a=input('Enter the +ve Shift:')
b=input('Enter the -ve shift:')
subplot(2,2,3)
c=a:a+N-1
stem(c,x)
xlabel('n-->')
ylabel('c(n)-->')
title('Delayed Shifted Signal:')
subplot(2,2,4)
d=b:b+N-1
stem(d,x)
xlabel('n-->')
ylabel('d(n)-->')
title('Advanced Shifted Signal:')

Write a Program to develop program module based on operatios on sequences like signal addition and signal multiplication.


n=0:3
x=input('Enter First Input Signal:')
y=input('Enter Second Input Signal:')
%First Input Signal
subplot(2,2,1)
stem(n,x)
xlabel('n-->')
ylabel('x(n)-->')
title('First Input Signal 1311977:')
%Second Input Signal
subplot(2,2,2)
stem(n,y)
xlabel('n-->')
ylabel('y(n)-->')
title('Second Input Signal by 1311977:')
%Addtion of First and Second Signal
subplot(2,2,3)
a=x+y
stem(n,a)
xlabel('n-->')
ylabel('a(n)-->')
title('Addition of Two Sequences by 1311977:')
%Multiplication of First and Second Signal
subplot(2,2,4)
m=x.*y
stem(m,a)
xlabel('n-->')
ylabel('m(n)-->')
title('Multiplication of Two Sequences by 1311977:')

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')

Tuesday 19 August 2014

Information Seeking Techniques


Why asking question,is an an extremely important for every Engineer,Civil service aspirant or as well as in the career?
The simple answer is for seeking information.Right questions brings right information while an ambiguous questions gives incomplete or wrong information.So there must be right question on a topic on issue at an appropriate time.
For example If an aspirant asks a question on the introductory part of the new foreign policy of the Government of India from a professor who is about to complete the lecture on the topic,most likely the professor would not answer it properly due to wrong timing of raising the question.But if he asks the same question from the same professor after he finishes the lecture,perhaps he would welcome the idea,giving him a detailed insight on the topic.So,it is absurd to ask questions on the introductory part about the topic which is reaching conclusion.In case a district magistrate gets a complaint against a block employee,will he suspend that employee on the basis of complaint only?Never,before doing so,he would probe the matter.To investigate the issue,he would seek information by questioning the employee and other sources.Having received complete information,he will think of final action.
So,by raising right questions in particular situation is an important part and you will gather better information,build stronger relationships,manage people more effectively and help others to learn,too.

Sunday 17 August 2014

Use of 'May and Might'

Hello friends it is often confusing for us where to use May and where to use might.Today in this post i will differentiate between these two modals.
Ok lets talk about the modal 'May'
May is used for taking formal permissions for example:May i come in sir.,May i borrow your pen.Remeber for taking formal permissions we usually use 'May' and not 'Can'.The sentence using can may be true but it is not used for taking formal permissions means 'Can' is not used when you are taking permissions from your boss,teacher,or from another peron who is higher in status than you.And for showing politeness or by asking questions politely we use 'May' eg.May i borrow your pen.Second use of May is when talking about of possibilities.When the possibilty of happening an event is greater we use may for example 1) He may come to stay with us. 2)It may rain today.
Now Lets move towards Might.
Might is used in the sentences in which the possibilty of happening an event is very very less.Remeber possibilty is very very less.For example 1)It might rain this yesterday.2)She might be at home.For negative sentences like I might not go to the market.Now lets talk about past possibilities.I might have forgotton my keys at the cafe(Have is a past participle).But i am not sure that i have forgotton my keys at the cafe but this may be the possibility.(If not sure and there is a less possibilty we use might)
hope you have understood the difference between these two.If any query feel free to ask.Keep enjoying friends......