You are on page 1of 12

INSTRUMENTATION AND MEASUREMENT LAB

TITLE: TO STUDY ABOUT DIFFERENT CONDITIONAL OPERATORS AND CURVE

FITTING TECHNIQUE USING LEAST SQUARE METHOD

NAME:

SHAHBAZ ZAFAR

REG NO:

190401085

LAB NO:

LAB INSTRUCTOR:

Mam Zile Huma


C.O.N.T.E.N.T.S
Page No.
Question 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3-5
 Basic logical and relational operations on basic matrix.
Question 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6
 Logical and relational operations on a little bit complex matrices.
Question 3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7
 Techniques of logical-indexing.
Question 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8-9
 Purpose of different MATLAB commands.
Question 5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9-10
 Curve fitting using least square method.
Conclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10
Question 1:

Exercise with logical and relational operators:

1. Predict and check the result of each of the operations given in above table for b = 0 and c = -1.

2. Predict and check the result of each logical operator for b = [2 31 -40 0] and c = 0.
3. Define two random vectors (randn(1,7)) and perform all logical operations, including ‘xor’, ‘any’ and ‘all’.
Question 2:

Exercise with logical and relational operators:


Let x = [1 5 2 8 9 0 1] and y = [5 2 2 6 0 0 2]. Execute and explain the results of the following commands:
Question 3:

Let x = 1 : 10 and y = [3 5 6 1 8 2 9 4 0 7]. The exercises here show the techniques of logical-indexing.
Execute and interpret the results of the following commands:

a) (x > 3) & (x < 8)


b) x (x > 5)
c) y (x <= 4)
d) x ((x < 2) | (x >= 8))
e) y ((x < 2) | (x >= 8))
f) x (y < 0)
Question 5:
Write down the MATLAB Code using technique of least square method for the following vectors and compare your
results with actual measured results.
X=[1 2 3 4 5]
Y=[2 5 7 9 11]

Question 4:
Explain the purpose of following commands:
Diary, eye, magic, rank, linspace, fplot, mesh, surf, contour, surface.

Diary:
diary command is used to keep an activity log of matlab session without graphics.

Eye:
eye (MATLAB Functions) Y = eye(n) returns the n -by- n identity matrix. Y = eye(m,n) or eye([m n]) returns an
m -by- n matrix with 1 's on the diagonal and 0 's elsewhere.

Magic:
magic (MATLAB Functions) M = magic(n) returns an n -by- n matrix constructed from the integers 1 through
n^2 with equal row and column sums.

Rank:
The rank function provides an estimate of the number of linearly independent rows or columns of a full
matrix.

Linspace:
The linspace function generates linearly spaced vectors.,

Fplot:
fplot( f ) plots the curve defined by the function y = f(x) over the default interval [-5 5] for x ,

Mesh:
mesh(X,Y,Z) creates a mesh plot, which is a three-dimensional surface that has solid edge colors and no face
colors,

Surf:
surf( X , Y , Z ) creates a three-dimensional surface plot, which is a three-dimensional surface that has solid
edge colors and solid face colors.

Contour:
contour( Z ) creates a contour plot containing the isolines of matrix Z , where Z contains height values on
the x-y plane.

Surface:
surface(X,Y,Z) creates a primitive, three-dimensional surface plot. The function plots the values in matrix Z
as heights above a grid in the x-y plane defined by X and Y. The color of the surface varies according to the heights
specified by Z.
Conclusion:
In this lab we learned to used basic commands of greater than smaller
them etc. and learned about some other commands like fplot, mesh
etc. We also learnt curve fitting using least square.

You might also like