MATLAB program to find out the Fourier Transform of sinusoidal waveform

Program code
clc;
clear all;
close all;
t=0:0.001:1;
cwtstruct = cwtft((sin(2*3.14*1000*t)),'plot');


Output


________________________

If you find this program code useful, then please deposit 5 Indian Rupees in my bank account, as my fee. (Citizens of Pakistan cannot do this.).
I am the woman who wrote this program code.
My name: Anju K.
My bank account number: 30221619108
Bank: State Bank of India, Chakkarakkal branch, India.
IFSC code: SBIN0070728
SWIFT code: SBININBB
BIC code: SBININBB
My email: tc9749@gmail.com .



MATLAB program to perform linear convolution of two signals ( without using MATLAB function)

Program Code
clc;
close all;
clear all;
xt=input('Please enter the input sequence in time domain x[n]= ');
lxt=length(xt);
ht=input('Please enter the impulse sequence h[n]= ');
lht=length(ht);
ext=[xt zeros(1,(lht-1))];
eht=[ht zeros(1,(lxt-1))];
xdft=fft(ext);
hdft=fft(eht);
freqm=xdft.*hdft;
yt=[ifft(freqm)];
display('The convoluted sequence is given below');
disp(yt);
subplot(311);
stem(xt);
xlabel('Time');
ylabel('Magnitude');
title('Input sequence x[n]');
subplot(312);
stem(xt);
xlabel('Time');
ylabel('Magnitude');
title('Input sequence 1');
subplot(313);
stem(yt);
xlabel('Time');
ylabel('Magnitude');
title('Convoluted sequence');


Example of Output
Please enter the input sequence in time domain x[n]= [1 2 3 4 5 6]
Please enter the impulse sequence h[n]= [1 2 3 4 5 6]
The convoluted sequence is given below
  Columns 1 through 5 

    1.0000    4.0000   10.0000   20.0000   35.0000

  Columns 6 through 10 

   56.0000   70.0000   76.0000   73.0000   60.0000

  Column 11 

   36.0000



Matlab program to find the linear convolution of two signals (using matlab functions)

Program Code
%linear convolution (using matlab functions)
clc;
close all;
clear all;
x1=input('Please enter the input sequence x[n]= ');
x2=input('Please enter the starting time index of x[n]= ');
h1=input('Please enter the impulse response h[n]= ');
h2=input('Please enter the starting time index of h[n]= ');
y=conv(x1,h1);
n=x2+h2:length(y)+x2+h2-1;
display('The convoluted sequence is given below:');
y
stem(n,y);
xlabel('Time');
ylabel('Amplitude');
title('Linear Convolution');



Example of Output
Please enter the input sequence x[n]= [4 3 1 2]
Please enter the starting time index of x[n]= -2
Please enter the impulse response h[n]= [1 4 3]
Please enter the starting time index of h[n]= -1
The convoluted sequence is given below:

y =


     4    19    25    15    11     6

_________________________________

If you find this program code useful, then please deposit 5 Indian Rupees in my bank account, as my fee. (Citizens of Pakistan cannot do this.).
I am the woman who wrote this program code.
My name: Anju K.
My bank account number: 30221619108
Bank: State Bank of India, Chakkarakkal branch, India.
IFSC code: SBIN0070728
SWIFT code: SBININBB
BIC code: SBININBB
My email: tc9749@gmail.com .


Matlab program to generate logarithmic curve


Program code
clc;
close all;
clear all;
a=input('Please enter the multiplication factor');
t=0:0.001:1;
p=log(a*t);
plot(p);
xlabel('Time');
ylabel('Amplitude');
title('LOGARITHMIC CURVE');
grid on;



Example of output
Please enter the multiplication factor 6

_______________________________

If you find this program code useful, then please deposit 5 Indian Rupees in my bank account, as my fee. (Citizens of Pakistan cannot do this.).
I am the woman who wrote this program code.
My name: Anju K.
My bank account number: 30221619108
Bank: State Bank of India, Chakkarakkal branch, India.
IFSC code: SBIN0070728
SWIFT code: SBININBB
BIC code: SBININBB
My email: tc9749@gmail.com .


Matlab program for Trapezoidal waveform


Program Code
clc;
clear all;
close all;
t=0:.5:4;
y=trapmf(t,[.5 1 2 2.5]);
plot (t,y);
axis ([0 4 -2 2]);
xlabel ('Time');
ylabel ('Amplitude');
title ('Trapezoidal Waveform');
grid on;                                         




Output 



Explanation of Program Code

 clc;
It clears all input and output from the Command Window display giving clean screen. It removes items from workspace, freeing up system memory. After using clc, the scroll bar cannot be used to see the history of functions, but still the up arrow can be used to recall statements from the command history.

clear all;
It removes all variables from the workspace. This frees up system memory.

close all;
It deletes all figures whose handles are not hidden.

t=0:.5:4;
It results in      
t =[0        .5     1      1.5           2      2.5      3         3.5          4]
Here a vector t is created having starting element as 0.5 and last element as 4 and with an increment of 0.5 between the elements. Here this vector t is used as time axis(x axis) while plotting trapezoidal waveform.

y=trapmf(t,[0.5 1 2 2.5]);
It is used to create trapezoidal curve. Trapmf is trapezoidal-shaped built-in membership function of fuzzy logic toolbox.The trapezoidal curve is a function of a vector, t , and depends on 0.5, 1, 2 and  2.5as given by
f(t,0.5, 1, 2, 2.5)=
 max{min{(t-0.5)/(1-0.5),  1, (2.5-t)/(2.5-2)}  0}
=max{min{(t-0.5)/0.5,   1,   (2.5-t)/0.5}           0}
0.5 and 2.5 locate the "feet" of the trapezoid.
1 and 2 locate the "shoulders" of the trapezoid.
          
plot (t,y);
It plots all the lines defined by t versus y pairs.

axis ([0 4 -2 2]);
It sets the limits for the x- and y-axis of the current axes.
Here according to the above command x-axis begins at 0 and ends at 4. Here y-axis begins at -2 and ends at 2.

xlabel ('Time');
It labels the x-axis as 'Time'. Each axes graphics object can have one label for the x-, y-, and z-axis. The label appears beneath its respective axis in a two-dimensional plot

ylabel ('Amplitude');
It labels the y-axis as ' Amplitude. '

title ('Trapezoidal Waveform');
It outputs the phrase  'Trapezoidal Waveform' above the figure at the top.

grid on; 
It adds major grid lines to the current axes.
_______________________

If you find this program code useful, then please deposit 5 Indian Rupees in my bank account, as my fee. (Citizens of Pakistan cannot do this.).
I am the woman who wrote this program code.
My name: Anju K.
My bank account number: 30221619108
Bank: State Bank of India, Chakkarakkal branch, India.
IFSC code: SBIN0070728
SWIFT code: SBININBB
BIC code: SBININBB
My email: tc9749@gmail.com .