Professional Documents
Culture Documents
AIM:- Generate Arrays and matrix and perform basic operations using Matlab
software.
Program:
% Creating a arrray
>> a=[1 2 3 4]
a=
1 2 3 4
% Creating a column vector
b=[1;2;3]
b=
1
2
3
% Creating a matrix
A=
1 2 3
4 5 6
7 8 9
B=
9 8 7
6 5 4
3 2 1
C=
30 24 18
84 69 54
138 114 90
>> D=A.*B
D=
9 16 21
24 25 24
21 16 9
%invesre of a matrix
>> inv(A)
ans =
>> x1=A(2:3,2:3)
x1 =
5 6
8 9
>> x2=A(:,2)
x2 =
2
5
8
% extracting row vector from matrix
>> x3=A(3,:)
x3 =
7 8 9
% transpose of a matrix
>> A'
ans =
1 4 7
2 5 8
3 6 9
x5 =
>> x6=A.^3
x6 =
1 8 27
64 125 216
343 512 729
AIM:- To Plot the basic signals like Unit Ramp, Impulse, Unit Step, Square Wave
and Sinc Functions using MATLAB.
Theory:
If the amplitude of the signal is defined at every instant of time then it is called
continuous signal. If the amplitude of the signal is defined at only at some instants
of time then it is called discrete signal. If the signal repeats itself at regular
intervals then it is called periodic signal. Otherwise they are called aperiodic
signals.
Ramp sinal:
=0 other wise
=0 other wise
Sinc signal:
G(x)=(sinx)/x
ROGRAM:
clc;
clear all;
t=0:0.1:5;
y=t;
subplot(6,2,1); plot(t,y)
xlabel('time');
ylabel('amplitude');
title('ramp signal');
%generation of ramp sequence
subplot(6,2,2); stem(y)
xlabel('n');
ylabel('amplitude');
title('ramp sequence');
y1=(t==0);
subplot(6,2,3); plot(t,y1);
xlabel('time');
ylabel('amplitude');
title('impulse signal');
subplot(6,2,4); stem(y1);
xlabel('n');
ylabel('amplitude');
title('impulse sequence');
%generation of unit step signal
y2=(t>=0);
subplot(6,2,5); plot(t,y2);
xlabel('time');
ylabel('amplitude');
subplot(6,2,6);stem(t,y2);
xlabel('n');
ylabel('amplitude');
subplot(6,2,7); plot(t,y3);
xlabel('time');
ylabel('amplitude');
subplot(6,2,8); stem(y3);
xlabel('n');
ylabel('amplitude');
%generation of sinusoidal
t1 = -3:0.1:3;
y4=sin(t1);
subplot(6,2,9); plot(t1,y4);
xlabel('time');
ylabel('amplitude');
title('sinsoidal wave signal');
subplot(6,2,10); stem(y4);
xlabel('n');
ylabel('amplitude');
y5=sinc(t1);
subplot(6,2,11); plot(t1,y5);
xlabel('time');
ylabel('amplitude');
subplot(6,2,12); stem(y5);
xlabel('n');
ylabel('amplitude');
title('sinc sequence');