0% found this document useful (0 votes)
82 views18 pages

Lab Work 1,2

This lab manual covers basic MATLAB operations including creating vectors, performing arithmetic operations on vectors, plotting graphs, and analyzing grade distribution data. In the first question, the student is asked to create a vector from -3 to 3 with an increment of 1 and find the absolute value and square root of each element. Subsequent questions involve dividing and taking remainders of vectors, computing exponential and logarithmic functions of vectors, and using the sign function. Later questions demonstrate changing between numeric formats, computing trigonometric functions in radians and degrees, plotting multiple graphs on the same figure, sorting and graphing grade data, and creating a histogram to analyze grade distribution.

Uploaded by

Shehzad khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views18 pages

Lab Work 1,2

This lab manual covers basic MATLAB operations including creating vectors, performing arithmetic operations on vectors, plotting graphs, and analyzing grade distribution data. In the first question, the student is asked to create a vector from -3 to 3 with an increment of 1 and find the absolute value and square root of each element. Subsequent questions involve dividing and taking remainders of vectors, computing exponential and logarithmic functions of vectors, and using the sign function. Later questions demonstrate changing between numeric formats, computing trigonometric functions in radians and degrees, plotting multiple graphs on the same figure, sorting and graphing grade data, and creating a histogram to analyze grade distribution.

Uploaded by

Shehzad khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Name: SHEHZAD KHAN

Cms: 46492

LAB MANUAL: ANM

Department PNG 5TH

Submitted to: SIR MUDASSAR IQBAL


Lab No 1

Objective:Introduction to MATLAB basics.

QNO1:

Create a vector x from -3 to +3 with an increment 1. Your vector should be X=[-3,-2,-


1,0,1,2,3] :

Find

(a) Find the absolute value of each member of the vector

(b)Find the square root of each member of the vector

Solve:

For increment we use colon sign in matlab to jump upto desire values ofour need syntex will
be X=-3:3
QNO2:

Create a vector x from -9 to 12 with an increment of 3.

(a) Find the result of x divided by 2

(b) Find the remainder of x divided by 2

Solve:

To make increament of 3 we use colon as

X=-9:3:12

Where 3 indicate the increament factor.

To divide x by 2 we use syntex X/2.

To find remainder we use rem(X).

AS:
QNO3:

Use the vector in Question 2, Find ex

Solve

Just write exp(X)

AS:
QNO4:

Use the vector in Question 2,

(a) Find ln(x)

(b) Find log10(x)

Solve:

To compute In(x),we write log(x).

To compute log10(x)we write log10(x).


QNO5:

Use the vector in Question 3, Use sign function to determine which of elements in vector x
are positive.

Solve:

By using sign fuction we can determined positive and negative numbers.If Matlab gives 0
number it means it is negative number if it gives 1 means it is positive number.
Lab No 2

Objective:Different operation in MATLAB.

QNO1:

Display the value of the vector x divided by 2

1}Change the format to rat .

2}Change back the format short or format long after you’ve completed this question.

Solve:

To change format from any number to rational number we write {rat()}to change it.

By writing format short or format long we change rational number to floating number upto 4
or 16 dight.
QNO2:

Find the cosine of o 45 .

(i) Convert the angle from degrees to radians, and then use the cos function
(ii) (ii) Use the cosd function.

Solve:

To change angle to radian we write a command ang2rad(ang).

When we use trignometry function without d it means to write radian in it.if we use d as cosd
mean angle can be used to find trignometry value.
QNO3:

Given x=[1,2,5,4,8,10]; y=[x;1:6];

Plots bar chart for x and y, three dimensional bar chart for y and pie chart for x on the same
figure windows (use subplot)
QNO4:
Let the vector G=[68,83,61,70,75,82,57,5,76,85,62,71,96,78,76,68,72,75,83, 93] Represent
the distribution of final grades in MATLAB for Engineering course.

(a) Use MATLAB to sort the data and create a bar graph of the scores

(b) Create a histogram of the scores, using hist.

Solve:

The histc function can be used to determine the number of A’s, B’s,C’s,D’s and E’s in the
grade data, if the following grading schemes applies A> 90 to 100, B> 80 to 90, C> 70 to 80,
D> 60 to 70 E> 0 to 60 Use the bar function to create histogram based on this scheme.
1
Combine graphs of grads and E variable:

You might also like