0% found this document useful (0 votes)
125 views

Probability and Statistics: Submitted To

This document describes a probability and statistics lab experiment conducted in MATLAB. The objective was to get familiar with entering data, using data, and plotting in MATLAB. Key skills covered included using commands for inputting data, creating matrices of zeros, plotting functions, performing calculations using for loops, and saving work regularly. Plots were generated of four functions against x from 0 to 64. Values were also calculated for several functions using input x and y values.

Uploaded by

Roshan Aslam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views

Probability and Statistics: Submitted To

This document describes a probability and statistics lab experiment conducted in MATLAB. The objective was to get familiar with entering data, using data, and plotting in MATLAB. Key skills covered included using commands for inputting data, creating matrices of zeros, plotting functions, performing calculations using for loops, and saving work regularly. Plots were generated of four functions against x from 0 to 64. Values were also calculated for several functions using input x and y values.

Uploaded by

Roshan Aslam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Probability and Statistics lab 2018-MC-274

Probability and Statistics

Submitted to:
Engr. Saqib Zafar
Submitted by:
Maria Munawar Ali
Reg No.:
2018-MC-274

Department of Mechatronics & Control Engineering


University of Engineering & Technology, Lahore fsd campus
Lab 1
1
Probability and Statistics lab 2018-MC-274

Introduction to MATLAB
Objective:
To get familiar with data entering, data utilizing and plotting in MATLAB.

Introduction:

MATLAB:
MATLAB is widely used in all areas of applied mathematics, in education and research at
universities, and in the industry. MATLAB stands for MATrix LABoratory and the software
is built up around vectors and matrices. This makes the software particularly useful for linear
algebra but MATLAB is also a great tool for solving algebraic and differential equations and
for numerical integration. MATLAB has powerful graphic tools and can produce nice
pictures in both 2D and 3D. It is also a programming language, and is one of the easiest
programming languages for writing mathematical programs. The MATLAB environment (on
most computer systems) consists of menus, buttons and a writing area similar to an ordinary
word processor.  MATLAB is case sensitive. This means that MATLAB knows a difference
between letters written as lower and upper case letters. For example, MATLAB will
understand sin(2) but will not understand Sin(2).

Command window:
The writing area that you will see when you start MATLAB, is called the command window.
In this window you give the commands to MATLAB. Debugging is usually done in
command window. Command window is called MATLAB interface.

Workspace:
The Workspace browser enables you to view and interactively manage the contents of the
workspace in MATLAB. For each variable or object in the workspace. You can edit the
contents of scalar (1-by-1) variables directly in the Workspace browser. Right-click the
variable and select Edit Value. To edit other variables, double-click the variable name in the
Workspace browser to open it in the Variables editor.

Editor:
The MATLAB Variables editor provides a convenient interface for viewing, modifying, and
plotting dataset arrays.
You can reorder variables in a dataset array using the Variables editor. You can enter new
data values directly into the Variables editor.
Command History window:
The commands you type in the command window are stored by MATLAB and can be viewed
in the Command History window. To repeat a command, you have already used, you can
simply double-click on the command in the history window, or use the <up arrow> at the

2
Probability and Statistics lab 2018-MC-274

command prompt to iterate through the commands you have used until you reach the
command you desire to repeat.

Input command:
Request user input displays the text in prompt and waits for the user to input a value and
press the Return key. It is used for data entering.

Syntax:
x = input(prompt)
Zeros: It creates an array of all zeros.
Syntax:
X = zeros(sz1,...,szN)
Plot:
Plot creates a 2-D line plot of the data in Y versus the corresponding values in X.

Syntax:
plot(X,Y)
Procedure:
 I opened MATLAB in my PC and opened a new script.
 I created a zero matrix of 10 by 3 equal to a variable “A”. then I used input command in
for loop so that every time I run the program it ask the user to input the values of the
matrix.

Figure1.1: Data entering in MATLAB


 To call any entry we write the matric name and specified position of any entry i.e,
variable(row,coloum).
 To index a row after comma a colon is used and to index column colon is used before
comma.

3
Probability and Statistics lab 2018-MC-274

Figure1.2: data recieved


Task 1: Plot the given four functions for 0≤ x ≤ 64 and step size of 0.5.
1. y = x 1
x
2. y = x(log2 ) 2
x 2
3. y = x (log 2 ) 3
2
4. y = x 4
 I used plot command to plot the given function against x.
 I plotted the four different functions on a same graph by using hold on command.

Figure 1.3: Plotting functions

Figure 1.4: Graph of given functions

4
Probability and Statistics lab 2018-MC-274

Task 2: Find the out of given functions for x = [1,2,3,4,5] and y = [6,7,8,9,10].
5 5
1. ∑ x i ∑ yi 5
i=1 i=1

5
2. ∑ xi yi 6
i=1

5
3. ∑ log10 x i 7
i=1

5
4. √ ∑ 5 x i+ y i
i=1
8

5
5. ∑|2 x i+5 y i| 9
i=1

6. e ∑xi
i=1 10
I opened a new script and saved it I declare the given x and y variables.I declared the
functions and find the summations in the functions by using for loop.

5
Probability and Statistics lab 2018-MC-274

Figure 1.5: Code to find output of functions

 I run the program to see the output in command window.

Figure 1.6: Output in command window


 During working on MATLAB I continue to save my work piece after every step so I may
not lose any data.

Conclusion:
From this lab I became familiar with commands for data entering, data utilizing & plotting in
MATLAB.

You might also like