You are on page 1of 26

INSTRUMENTATION AND MEASUREMENT LAB

TITLE:

INTRO TO MATLAB

NAME:

SHAHBAZ ZAFAR

REG NO:

190401085

LAB NO:

LAB INSTRUCTOR:
Mam Zile Huma
Objective:
1. To become familiar with the MATLAB software.

2. Use MATLAB to perform matrix operations.

3. Generate and Plot signals using plot and stem functions.

Question 1:

1. If y has not been assigned a value, Will MATLAB allow you to define the equation x = y ^2
to store in memory for later use?

Yes, MATLAB allow to define the equation x = y ^2 to store in memory for later use without
declaring variables. If we do not end the assignment statement with a semicolon , MATLAB
displays the result in the Command Window. Each time y is assigned a value depending on
the value of x.

2. If the volume of a cylinder of height h and radius r is given by V = πr2h, use MATLAB to
find the volume enclosed by a cylinder that is 12 cm high with a diameter of 4 cm.
3. Display the results of sin (π/4), sin (π/3), and sin (π/2) as rational numbers. Also
consider the phase as degrees.

4. Compute ex for a few values of x. You must take minimum 20 values and take the input as
vectors.
Question 2:
Solve the following set of linear equations; also find the determinant of each of the following

3x 2y 5
6x 2y 2
x 2y z 3
5y z 2

3x 2y z 7
4y z 2
3x 2y 9z 65
9x + 5y 2z 16
6x 7y 3z 5

x 2y 3z = 12
4x y 2z = 13
9y 8z = 1
x 2y 3z = 1
x 4y 3z = 2
2x 8y z = 

x 7y 9z = 12
x y 4z = 16
x y 7z = 16
2w + 4x - 3y + 29z =20
12w + 8y + 2z =10
-5w + x + 10z =40
w +x + y +z =20

5x 2y 9z 44


9x 2y 2z 11
6x 7y 3z 44
Question 3:
Discuss the different format types used in MATLAB. Please write in your own words and it must
not exceed more than 5-lines.

Format types are used to vary the precision of output (decimal places), output display and spacing
between variables. Short data format is a fixed point format with 5 digits. Long data format is a fixed
point format with 14 digits. Short e data format is a format with 5 digits and exponent. Long e data
format is a f format with 14 digits and exponent.

Question 4:
Explain with examples how to add rows and columns in a defined matrix.

Question 5:

Plot the following functions, Take any input vector

1. Y=cos(x)
Y=sinx

Z=tanx

Y=sininv(x+2)
Y=ex+tanhx

Y=taninv(x+8)

Y=ex.sinx
Y=sinx.cosx

Y=tanx+2ex
Y=e^-x

Question 7:
Use the functions given in Question 5; plot multiple functions on same figure,

1. Display them in different colors(Color Specifier are given in the end)


2. Different Notations.

Question 8:
Plot the function Y= cos (T) for the following input vectors, also discuss its effects on the output
plot:

1. T=[0:100];

2. T=[0:0.1:100];
3. T=[0:0.001:100];

QUESTION6:

Repeat Q5 using stem

Y=cos(x)

Y=sin(x)
Z=Tan(x)

Y=ex + tanh(x)
Y=sin-1(x+2)

Y=tanh-1(x+8)
Y= ex .sin(x)

Y=sin(x).cos(x)
Y=tan(x)+2ex

Y=e-x
Question 4:
Explain with examples how to add rows and columns in a defined matrix.

ROW VECTOR

ADDING ROW

ADDING COLUMN
COLUMN VECTOR

Adding row

Adding column
2D vector

Adding row

Adding Column
3D vector

Adding row

Adding column

You might also like