You are on page 1of 14

ICT CO1

MATLAB as a Calculator

shs.mapua.edu.ph
MATLAB as a Calculator
One of the main functions of MATLAB is it’s main ability to calculate
complicated Mathematical problems, it is used by engineers, architects,
students, etc.

shs.mapua.edu.ph
SYMBOLS USE FOR ARITHMETHIC COMPUTATION
you can use this symbols to make calculations in the MATLAB operation!

Adding Subtracting Multiplying Power Dividing

+ - * ^ /

• Use to add • Use for • Use to multiply • Use to make a • Use for
variables subtracting variables variable a dividing
variables power to a variables to
variable variables

shs.mapua.edu.ph
Example:
Multiply x and y and divide the answer by 2 and add 4 and subtract 6
X=3
Y=4
Program:
>>3*4
12
>>12/2
11
>>11+4
15
>>15-2
13

shs.mapua.edu.ph
Try this exercise:
• Calculate the problem by using this formula 4 is the power by 5 and
divided by 6 and multiplied by 8.

shs.mapua.edu.ph
CO2
Information and Communication
Technology

shs.mapua.edu.ph
Two-Dimensional Plotting
Feature’s
• 2D Plots in Matlab is a feature that enables a user to create the two-
dimensional graph for any dependent variable as a function of a
depending variable.

shs.mapua.edu.ph
 Semilogx ( X , Y ) - they plots x- and y-coordinates using a base-10 logarithmic scale on
the x-axis and a linear scale on the y-axis. To plot a set of coordinates connected by
line segments, specify X and Y as vectors of the same length.

 loglog () function - is a 2D plot creation function that generates a plot with a


logarithmic scale (base 10). It plots data sets of both 'x' and 'y' axes in the logarithmic
scale. It is basically useful to generate plot either for very large values or very small
positive values.

 ezplot ( f ) plots a symbolic expression, equation, or function f .

 plot -function in MATLAB is used to create a linear graphical representation of some


data.

shs.mapua.edu.ph
Examples
Plot the Domain 2π using with the range of 0<0<100
 Plot
 Semilogx
 Semilogy
 Loglog
 ezplot

shs.mapua.edu.ph
Forms of axis Command
COMMAND FUNCTION
Returns a row vector containing scaling factors for the x-, y-,
v = axis and z-axis.
Sets the limits for the x- and y-axis of the current axes.
axis([xmin xmax ymin ymax])
Sets the aspect ratio so that the data units are the same in
axis equal every direction.
Makes the current axes region square (or cubed when three-
axis square dimensional).
uses the default aspect ratio for the plot, axis square makes the aspect ratio
square, axis equal uses the same length for the data units along each axis, and
axis tight sets the axis box tightly around the data.
axis normal
axis visibility , where visibility is off/on , turns off/on the display of the axes
background.
axis on/off

shs.mapua.edu.ph
Adding a color, marker, and linestyle to your
graph
COLORS MARKERS LINE STYLES
Yellow Y Point . Dashed --
Magenta m X-mark x Dashdot -.
Cyan c Star * Dotted :
Red r Plus-mark + Solid -
Green g Circle o
Blue b Square s Triangle ^
White w Diamond d Pentagram p
Black k Triangle v Hexagram h

shs.mapua.edu.ph
How to graph two graphs at
the same time?
 In order for you to graph 2 graphs at the same time you must use the function
hold on in MATLAB
 Ex.
>>”Program of graph 1”
>>hold on
>>”Program of graph 2”

shs.mapua.edu.ph
CO3
Introduction to Top-Down Design Techiniques

shs.mapua.edu.ph
State the problem you are tying to solve

Define required inputs and outputs

Design the algorithm

Convert the algorithm into MATLAB statement

Test the resulting MATLAB program

shs.mapua.edu.ph

You might also like