Professional Documents
Culture Documents
What is MATLAB?
Matrix Laboratory
MATLAB BASICS
Engr. Patrick Renz M. Bautista ECE # 47680
A numerical computing environment and fourth generation programming language. Allows matrix manipulations, plotting of functions and data, implementations of algorithms, creation of user interfaces, and interfacing with programs written in other languages (C, C++, Java and Fortran)
A programming environment for algorithm development, data analysis, visualization, and numerical computation. - MathWorks
MATLAB Application
Signal and Image Processing Communications Control Design Test and Measurement Financial Modelling and Analysis Computational Biology
VARIABLES
DEFINITION
VARIABLES
Variables are assigned numerical values by typing the expression directly.
For example: a = 1+2 Yields a = 3
VARIABLES
A variable can be assigned using a formula that utilizes these operators and either numbers or previously defined variables.
Since a was defined previously, the following expression is valid: b = 2*a;
To determine the value of a previously defined quantity, type the quantity by itself: b yields: b = 6
6/30/2013
VARIABLES
If your expression does not fit on one line, use an ellipsis (three or more periods at the end of the line) and continue on the next line. c = 1+2+3+... 5+6+7; Predefined Variables:
i sqrt(-1) j sqrt(-1) pi 3.1416...
VARIABLES
For Example, y= 2*(1+4*j) yields: y= 2.0000 + 8.0000i
Predefined Functions:
abs angle cos sin exp magnitude of a number (absolute value for real numbers) angle of a complex number, in radians cosine function, assumes argument is in radians sine function, assumes argument is in radians exponential function
VARIABLES
For example. With y defined as above
c = abs(y) yields: c = 8.2462 c = angle(y) yields: c = 1.3258 With a=3 as defined previously, c = cos(a) yields: c = -0.9900 c = exp(a) yields: c = 20.0855
VARIABLES
Note that exp can be used on complex numbers.
c = exp(y) yields: c = -1.0751 + 7.3104i
Activity 1
Evaluate the following functions using MATLAB 1. A = 3(3+4) 2. B= area of a circle with a diameter of 4m. 3. C= 5 + (2 3)1 4. D = 430 3 + 3 5. E = surface area of the sphere with a radius of 5m 6. F = sin 30 7. G = cos 60 8. H = sin 90 9. I = sin 30 cos 60 + sin 60 cos 30 10. J = (355 )