University of Engineering & Technology Lahore: Experiment
University of Engineering & Technology Lahore: Experiment
# 2018-EE-427
Theory: -
MATLAB is a powerful computing system for handling the calculations involved in
problems
scientific and engineering . The name MATLAB stands for Matrix Laboratory,
because the system was designed to make matrix computations particularly easy. One of
the many things about MATLAB (and which distinguishes it from many other computer
programming systems, such as C++ and Java) is that you can use it interactively. This
means you type some commands at the special MATLAB prompt, and get the answers
immediately. The problems solved in this way can be very simple, like finding a square
root, or they can be much more complicated, like finding the solution to a system of
differential equations. For many technical problems you have to enter only one or two
commands, and you get the answers at once.
MATLAB WINDOWS: -
Window Purpose
Command Window Main window, enters variables, runs programs.
Figure Window Contains output from graphic commands.
Editor Window Creates and debugs script and functon fles.
Help Window Provides help informaton.
Launch Pad Window Provides access to tools, demos, and documentaton.
Command History Window Logs commands entered in the Command Window
Workspace Window Provides informaton about the variables that are used.
Current Directory Window Shows the fles in the current directory
Workspace Window
Command Window
Command
History Window
Procedure: -
Display formats
Command Descripton Example
format short Fixed-point with 4 decimal digits for: >> format short
0.001 ≤ number ≤1000 Otherwise display >> 290/7 ans =
format short e. 41.4286
format long Fixed-point with 14decimal digits. >> format long >>
290/7
ans = 41.428571428571431
format short e Scientfc notaton with 4 decimal digits. >> format short e
>> 290/7
ans = 4.1429e+001
format long e Scientfc notaton with 15 decimal digits. >> format long e >>
290/7
ans =
4.142857142857143e+001
format short g Best of 5-digit fxed or foatng point. >> format short g
>> 290/7
ans = 41.429
format long g Best of I5-digit fxed or foatng point. >> format long g >> 290/7
ans = 41.4285714285714
Rounding functons
Functon Descripton Example
round (x) Round to the nearest >> round (17/5)
integer. ans = 3
fx(x) Round towards zero. >> fx (13/5)
ans = 2
ceil(x) Round towards infnity. >> ceil (11/5)
ans = 3
foor (x) Round towards minus >> foor(-9/4)
infnity. ans = -3
rem(x,y) Returns the remainder >> rem(13,5)
after x is divided by y. ans = 3
sign(x) Signum functon. Returns 1 >> sign(5)
if ans = 1
x > 0 , -1 if x < 0, and 0 if x =
0
Q-1: Calculate;
Software:
Theoretical calculation:
Software:
Theoretical calculation:
Software:
Theoretical calculation:
Software:
Theoretical calculation:
Theoretical calculation:
Q-3: Defne the variable x and z as x = 9.6, and z=8.1, then evaluate.
Software:
Theoretical calculation:
Theoretical calculation:
Conclusion:
In this lab we have learn how to use MATLAB for the manipulation of basic
math operation as well as to solve the complex problems related to different fields of
engineering. MATLAB is useful math tool as it is capable of solving matrix, derivative,
integration and many more operation on ODEs with ability of making graphs of functions with
respect to time or other independent variables.