411 REFERENCE · Wikibooks
MATLAB Programming/Fundamentals of MATLAB/MATLAB operator
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
MATLAB Operator
MATLAB have a few operator types to manipulate shown below
Note: Variables a and b below represents number
Arithmetic Operations
Arithmetic Operator is used as mathematical operator that manipulates the number according to the formula requirement. The result is shown as numbers.
+ Arithmetic Operator Addition a + b Subtraction a - b Multiplication a * b Forward division a / b Backward division a \ b Exponentiation a ^ b Assignment a = b
Relational Operations
Relational Operator is used to check if numbers are having any significant relationship with one or another. The results is usually is shown TRUE or FALSE.
+ Relational Operator Equal To a == b Not Equal To a ~= b Greater than a > b Greater or equal to a >= b Lesser than a < b Lesser or equal to a <= b
Logical Operations
Logical Operator is used to check if number fulfills the logical conditions, the result is usually shown TRUE or FALSE.
+ Logical Operator Logical AND a && b Logical OR a || b Logical NOT a ~ b
Elementary Mathematics Constants and Functions
Besides mathematical formula, there are a few mathematical constant and function that you can use to make your works in Matlab easier.
More information about the functions used can be found here:Mathematical_symbols
pi Returns value of 3.1416 (Note: Ratio of a circle's circumference to its diameter) sqrt(a) Returns square root of a exp(1) Returns value of 2.7183 This is exponential function (Note: it is inverse of natural log, try log(exp(1) and see the result) log(a) This logarithm operator is to find natural number log of a number log10(a) This base10 log operator is common logarithm for base 10 mod(a,b) or rem(a,b) This modulo operator returns the remainder after a is divided by b. : (Colon) Generate a sequence round(a,b) This rounding operator round up to the number to the nearest digit "a" by the significant digit "b"
b > 0: round to a digits to the right of the decimal point.
b = 0: round to the nearest integer.
b < 0: round to a digits to the left of the decimal point. primes(a) Returns a list of prime numbers less than or equal to number a gcd(a,b) Returns the greatest common divisors of the number of a and b. lcm(a,b) Returns the least common multiples of the number of a and b.
Trigonometry Operations
thumb|Trigonometry Triangles
The trigonometry formula are given as followed:
Sin α - a / h
Cos α - b / c
Tan α - a / b
sin(α) This sine operator returns sine value of argument in radians sind(α) This sine operator returns sine value of argument in degree cos(α) This cosine operator returns cosine value of argument in radians cosd(α) This cosine operator returns sine value of argument in degree tan(α) This tan operator returns tangent value of argument in radians tand(α) This tan operator returns tangent value of argument in degree deg2rad(α) Convert angle from degrees to radian rad2deg(α) Convert angle from radians to degrees (Note: Try to convert the pi from radian to degrees)
Matrix Operations
[ ] Container for matrix , Matrix row separator ; Matrix column separator
Others
randi Random integer
MATLAB Programming