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

LAB 1 Matlab

This document provides an introduction and overview of MATLAB. It discusses the objectives of getting familiar with MATLAB's basic features, commands, and functions. It describes the MATLAB environment and components like the Command Window, Current Directory Window, Figure Window, Workspace Window, and Command History Window. It also covers getting started with MATLAB, operators and special characters, variables, and functions for working with complex numbers. Tasks are provided at the end to practice basic MATLAB skills like declaring variables, performing arithmetic operations, taking logs, and displaying real and imaginary parts of complex numbers.

Uploaded by

M Azeem
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views

LAB 1 Matlab

This document provides an introduction and overview of MATLAB. It discusses the objectives of getting familiar with MATLAB's basic features, commands, and functions. It describes the MATLAB environment and components like the Command Window, Current Directory Window, Figure Window, Workspace Window, and Command History Window. It also covers getting started with MATLAB, operators and special characters, variables, and functions for working with complex numbers. Tasks are provided at the end to practice basic MATLAB skills like declaring variables, performing arithmetic operations, taking logs, and displaying real and imaginary parts of complex numbers.

Uploaded by

M Azeem
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

LAB# 01

GETTING STARTED WITH


MATLAB
Introduction
MATLAB, which stands for Matrix Laboratory, is a very powerful program for performing
numerical and symbolic calculations, and is widely used in science and engineering, as well
as in mathematics. Objectives:
 This lab is designed to give you a quick way to become familiar with the MATLAB
software by introducing you the basic features, commands, and functions.
 In this lab, you will discover that entering and solving complex numbers in MATLAB is
as easy as entering and solving real numbers, especially with the help of MATLAB
built-in complex functions.
The MATLAB Environment:

Workspace
CommandWindow
Current
Folder

Command
History

MATLAB has the following basic window components:


 Command Window
 to execute commands in the MATLAB environment
 Current Directory Window
 to quickly access files on the MATLAB path
 Figure Window
 to display graphical output from MATLAB code
 Workspace Window
 to view variable definitions and variable memory allocations
 Command History Window
 Displays all commands issued in MATLAB since the last session (good for learning and
verification)
Getting Started
• When MATLAB starts the MATLAB prompt >>
appears.
• All MATLAB commands are executed from this
prompt.

• MATLAB assigns the result to variable name ‘ans’. A


percent sign is a comment and is ignored.

• By default MATLAB returns numerical expressions as decimals with 5


digits. The format function is used to change the format of the output.
Type format rat to have MATLAB return rational expressions.
Operators and Special Characters
+ Plus; addition operator.
- Minus; subtraction operator.
* Scalar and matrix multiplication operator.
/ division operator
.* Array multiplication operator.
^ Scalar and matrix exponentiation operator.
.^ Array exponentiation operator.
: Colon; generates regularly spaced elements and represents an entire row or
column.
() Parentheses; encloses function arguments and array indices; overrides
precedence.
[] Brackets; enclosures array elements.
. Decimal point.
… Ellipsis; line-continuation operator.
, Comma; separates statements and elements in a row.
; Semicolon; separates columns and suppresses display.
= Assignment (replacement) operator.
Variables
• To assign a value to a variable in MATLAB simply type the name of the variable,
followed by the assignment operator, =, followed by the value.

Note that variable names in MATLAB are case sensitive, so X and x are not equal.

New variables may be defined using existing variables.

• This, however, does not imply any permanent relationship between x and y. If we
change x, the value of y does not change.

Complex number:
Entering complex numbers from the keyboard has to be done carefully. The symbol "i"
identifies the imaginary part and has to be typed immediately after the numerical value of
the imaginary part: for example, 2 + 3i . If you insert a space - for instance, 2 + 3 i - it
looks like the same expression but it will be processed as a number ( 2 + 3 ) and a string
( i ), and not as the complex number (2 + 3i). It is also important to point out that
termination with the character i only works with simple numbers, not expressions. For
example, the expression ( 1 - 2i)i has no meaning to MATLAB. If you want to multiply a
complex expression by i, you have to use the multiplication operation symbol (*). In the
example above, you must write ( 1 - 2i)*i . Similarly, the number 1 - sin(2)i has no
meaning for MATLAB. It has to be written as 1 - sin(2)*i to make sense to the program.

Functions for Complex Numbers

Table2: some complex building function.


Command This returns the
Complex(x,y) Return a complex number x+yi
real(x) real part of a complex number
imag(x) imaginary part of a complex number
Abs(x) magnitude of the complex number
angle(x) angle of a complex number x
conj(x) complex conjugate of the complex number x
Cart2pol Convert Cartesian to Polar form of complex
number
Pol2cart Convert Polar to Cartesian form of complex
number

Tasks:
1. Declare two variables “x” and “y” assign any value to them and perform any
mathematical operation on it and store the result in “res”.
2. Now take the log of “res”.

3. Declare the variable x,y,z and solve the equation using arithmetic operator in
matlab command
• x2+2xy+y2
• x3y+4x2+7y3

4.Declare a complex number n=-8-20i and display its real part and imaginary part by
calling function real (n) and imag (n).
Levels
PLO
no Criteria Beginning (1) Developing (2) Accomplished (3) Exemplary (4)

Student is unable to apply With instructor/ supervisor’s With instructor/ Student is able to apply all
Apply Procedural
described procedure to guidance, student is able to supervisor’s guidance, procedural knowledge to
Knowledge to
1 perform activity despite apply some of the described student is able to apply all independently perform
perform an
instructor/ supervisor’s procedure to partially perform described procedure to fully activity without instructor/
activity
guidance. activity. perform activity. supervisor’s guidance.
With instructor/ Student is able to
Student is unable to design
Design systems, With instructor/ supervisor’s supervisor’s guidance, independently design
systems, components and/or
components guidance, student is able to student is able to fully systems, components and/or
processes to meet
3 and/or processes partially design systems, design systems, processes to meet
specifications despite
to meet components and/or processes components and/or specifications without
instructor/ supervisor’s
specifications to meet specifications. processes to meet instructor/ supervisor’s
guidance.
specifications. guidance.
With instructor/ Student is able to
Student is unable to analyze/ With instructor/ supervisor’s
Data Analysis and supervisor’s guidance, independently
interpret obtained results guidance, student is able to
4 interpretation of student is able to fully analyze/interpret obtained
despite instructor/ partially analyze/interpret
obtained results analyze/interpret obtained results without instructor/
supervisor’s guidance. obtained results.
results. supervisor’s guidance.
Operational Skills Student has shown little to no
for ability to handle/use With instructor/ supervisor’s With instructor/ Student can handle/use all
Hardware/Softwa equipment/software and guidance, student can supervisor’s guidance, equipment/software and
5 re equipment and involved components despite handle/use some of the student can handle/use all involved components
involved instructor/ supervisor’s equipment/ software and equipment/software and without instructor/
components guidance. involved components. involved components. supervisor’s guidance.

Student has shown little to no


regard for personal and With instructor/ supervisor’s With instructor/ Student has followed all
Follow personal
equipment safety regulations guidance, student followed supervisor’s guidance, safety rules and protocols
6 and equipment
despite instructor/ some of the personal and student followed all safety without instructor/
Safety Rules
supervisor’s guidance. equipment safety regulations rules. supervisor’s guidance.

Psychomotor Domain Rubrics


Activity Name  EXPERIMENT No. 1

Group No. 

Student Roll No.  12438

C P Domain +
N
L L Taxonomy Criteria Awarded Score (out of 4 for each cell)
o.
O O

1 P3 Operational Skills for Hardware/Software equipment and


5 5
involved components
2 6 10 A3 Effectively reported the activity performed in lab

- - - -

You might also like