Probability and Statistics: Submitted To
Probability and Statistics: Submitted To
Submitted to:
Engr. Saqib Zafar
Submitted by:
Maria Munawar Ali
Reg No.:
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.
3
Probability and Statistics lab 2018-MC-274
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
Conclusion:
From this lab I became familiar with commands for data entering, data utilizing & plotting in
MATLAB.