MATLAB for discrete and polynomials functions
A set of data is said to be discrete if the values belonging to the set are distinct and separate (unconnected values). In the graph of a discrete function, only separate, distinct points are plotted, and only these points have meaning to the original problem.
The basic matlab discrete functions are factor, factorials, gcd, isprime, lcm, nchoosek, perms, primes, rat and rats .
|factorials||Factorial of input|
|gcd||Greatest common divisor|
|isprime||Determine which array elements are prime|
|lcm||Least common multiple|
|nchoosek||Binomial coefficient or all combinations|
|perms||All possible permutations|
|primes||Prime numbers less than or equal to input value|
|rat||Rational fraction approximation|
These functions are used as follows in matlab:
y = factor(n) % It will generate a row vector y = factor(20) = 2 2 5 % Row and column vector will be discussed in next article Input value can be reproduced by multiplying the elements of y. Which is as follows: prod(y) =20
The factorial, symbolised by an exclamation mark (!), is a quantity defined for all integers greater than or equal to zero. The factorial value of 0 is defined as equal to 1. The factorial values for negative integers are not defined.
y = factorial(n)
y = factorial(n) returns the product of all positive integers less than or equal to n, where n is a nonnegative integer value. If n is an array, then f contains the factorial of each value of n. The data type and size of y is the same as that of n.
y = factorial(5) = 120 To evaluate factorial of longer digits you need to set format as follows: format long y = factorial(22) = 1.124000727777608e+21 Factorial of Array elements n = [0 1 2; 3 4 5]; y = factorial(n) = 1 1 2 6 24 120
G = gcd(A,B)
[G, U, V] = gcd(A, B)
G = gcd(A,B) returns the greatest common divisors of the elements of A and B. The elements in G are always nonnegative, and gcd(0,0)returns zero. This syntax supports inputs of any numeric type.
[G, U, V] = gcd(A, B) also returns the Bézout coefficients, U and V, which satisfy: A.*U + B.*V = G. The Bézout coefficients are useful for solving Diophantine equations. This syntax supports double, single, and signed integer inputs.
Note: gcd returns positive values only.
A = [-2 17; 10 0]; B = [-4 3; 100 0]; G = gcd(A,B) = 2 1 10 0
LCM stands for Least common multiple. Definition of LCM can be given as “It is a smallest common prime factor of two or more number except zero “.
L = lcm(A,B) % where A & B are numbers
L = lcm(A,B) produces least common multiple of A and B.
A = 5 B = 45 L = lcm(A,B) L = 45 LCM of an array and a sclar A = [5 17, 10 60]; B = 45; L = lcm(A,B) L = 45 765 90 180
A polynomials functions is mathematical expression which includes constant and variables along with arithmetic operators. Such as quadratic equations, cubic equations and higher order equation.
Some polynomial functions which are being used commonly:
|poly||Polynomial with specified roots or characteristic polynomial|
|ployeig||Polynomial eigenvalue problem|
|ployfit||Polynomial curve fitting|
|residue||Partial fraction expansion (partial fraction decomposition)|
|ployvalm||Matrix polynomial evaluation|
|conv||Convolution and polynomial multiplication|
|dconv||Deconvolution and polynomial division|