Monday, 30 May 2016

MATLAB Programming 22 - Functions for logical operators

Functions


all - Determine if all array elements are nonzero or true

any - Determine if any array elements are nonzero

false - Logical 0 (false)

find - Find indices and values of nonzero elements

islogical - Determine if input is logical array

logical - Convert numeric values to logicals

true - Logical 1 (true)

MATLAB Programming 21 - Logical Operators

Logical Operations

True or false (Boolean) conditions
The logical data type represents true or false states using the numbers 1 and 0, respectively. Certain MATLAB® functions and operators return logical values to indicate fulfillment of a condition. You can use those logical values to index into an array or execute conditional code. For more information, see how to Find Array Elements That Meet a Condition.

Functions

Logical Operators: Short-circuitLogical operations with short-circuiting
andFind logical AND
notFind logical NOT
orFind logical OR
xorFind logical exclusive-OR

Saturday, 28 May 2016

MATLAB Programming 20 - Functions for Relational Operators

Functions

eq             - Determine equality
ge             - Determine greater than or equal to
gt              - Determine greater than
le              - Determine less than or equal to
lt               - Determine less than
ne             - Determine inequality
isequal     - Determine array equality
isequaln  - Determine array equality, treating NaN values as equal



Friday, 27 May 2016

MATLAB Programming 19 - Relational Operators

Relational operator

Specify the operation for comparing two inputs or determining the signal type of one input.

==
TRUE if the first input is equal to the second input
~=
TRUE if the first input is not equal to the second input
<
TRUE if the first input is less than the second input
<=
TRUE if the first input is less than or equal to the second input
>=
TRUE if the first input is greater than or equal to the second input
>
TRUE if the first input is greater than the second input
isInf
TRUE if the input is Inf
isNaN
TRUE if the input is NaN
isFinite
TRUE if the input is finite


Wednesday, 25 May 2016

MATLAB Programming 18 - Functions for reminder

r = rem(a,b) returns the remainder after division of a by b, where a is the dividend and b is the divisor.

b = mod(a,m) returns the remainder after division of a by m, where a is the dividend and m is the divisor. This function is often called the modulo operation and is computed using b = a - m.*floor(a./m). The mod function follows the convention that mod(a,0) returns a.

Click Here To Watch Video...!

MATLAB Programming 17 - Rounding functions

Y = round(X) rounds each element of X to the nearest integer. In the case of a tie, where an element has a fractional part of exactly 0.5, the round function rounds away from zero to the integer with larger magnitude.

Y = ceil(X) rounds each element of X to the nearest integer greater than or equal to that element.

Y = fix(X) rounds each element of X to the nearest integer toward zero. For positive X, the behavior of fix is the same as floor. For negative X, the behavior offix is the same as ceil.

Y = floor(X) rounds each element of X to the nearest integer less than or equal to that element.

Click Here To Watch Video..!

MATLAB Programming 16 - sum()

S = sum(A) returns the sum of the elements of A along the first array dimension whose size does not equal 1.
  • If A is a vector, then sum(A) returns the sum of the elements.
  • If A is a matrix, then sum(A) returns a row vector containing the sum of each column.
  • If A is a multidimensional array, then sum(A) operates along the first array dimension whose size does not equal 1, treating the elements as vectors. This dimension becomes 1 while the sizes of all other dimensions remain the same.

S = sum(A,dim) returns the sum along dimension dim. For example, if A is a matrix, then sum(A,2) is a column vector containing the sum of each row.

S = sum(___,outtype) returns the sum with a specified data type, using any of the input arguments in the previous syntaxes. outtype can be 'default','double', or 'native'.

S = sum(___,nanflag) specifies whether to include or omit NaN values from the calculation for any of the previous syntaxes. sum(A,'includenan') includes all NaNvalues in the calculation while sum(A,'omitnan') ignores them.

MATLAB Programming 15 - prod()

B = prod(A) returns the product of the array elements of A.
  • If A is a vector, then prod(A) returns the product of the elements.
  • If A is a nonempty matrix, then prod(A) treats the columns of A as vectors and returns a row vector of the products of each column.
  • If A is an empty 0-by-0 matrix, prod(A) returns 1.
  • If A is a multidimensional array, then prod(A) acts along the first nonsingleton dimension and returns an array of products. The size of this dimension reduces to 1while the sizes of all other dimensions remain the same.
prod computes and returns B as single when the input, A, is single. For all other numeric and logical data types, prod computes and returns B as double.

B = prod(A,dim) returns the products along dimension dim. For example, if A is a matrix, prod(A,2) is a column vector containing the products of each row.

B = prod(___,type) returns an array in the class specified by type, using any of the input arguments in the previous syntaxes. type can be 'double''native', or 'default'.

MATLAB Programming 14 - diff()

Y = diff(X) calculates differences between adjacent elements of X along the first array dimension whose size does not equal 1


  • If X is a vector of length m, then Y = diff(X) returns a vector of length m-1. The elements of Y are the differences between adjacent elements of X.
    Y = [X(2)-X(1) X(3)-X(2) ... X(m)-X(m-1)]
  • If X is a nonempty, nonvector p-by-m matrix, then Y = diff(X) returns a matrix of size (p-1)-by-m, whose elements are the differences between the rows of X.
    Y = [X(2,:)-X(1,:); X(3,:)-X(2,:); ... X(p,:)-X(p-1,:)]
  • If X is a 0-by-0 empty matrix, then Y = diff(X) returns a 0-by-0 empty matrix.

Y = diff(X,n) calculates the nth difference by applying the diff(X) operator recursively n times. In practice, this means diff(X,2) is the same asdiff(diff(X)).

Y = diff(X,n,dim) is the nth difference calculated along the dimension specified by dim. The dim input is a positive integer scalar.

Monday, 23 May 2016

MATLAB Programming 13 - cumprod() & cumsum()

Learn two functions cumprod() and cumsum() used in MATLAB.

Click Here To Watch Video..!

MATLAB Programming 12 - Functions for arithmetic operations - 1

Learn some functions for arithmetic operations used in MATLAB.

Click Here To Watch Video..!

This video is PART 1 

MATLAB Programming 11 - creating M files

Learn how to create M files in MATLAB.

Click Here To Watch Video..!

MATLAB Programming 10 - commands used to manage a session

Learn some commands used to manage a session in MATLAB.

Click Here To Watch Video..!

MATLAB Programming 9 - creating vectors

Learn how to create vectors in MATLAB.

Click Here To Watch Video..!

Sunday, 22 May 2016

MATLAB Programming 8 - format function

By default, MATLAB displays numbers with four decimal place values. This is known as short format.

However, if you want more precision, you need to use the format command.

The format long command displays 16 digits after decimal.

For example:
format long
x = 7 + 10/3 + 5 ^ 1.2
MATLAB will execute the above statement and return the following result:
x =
17.231981640639408

Another example,
format short
x = 7 + 10/3 + 5 ^ 1.2
MATLAB will execute the above statement and return the following result:
x =
17.2320

The format bank command rounds numbers to two decimal places.

For example,
format rat
The format rat command gives the closest rational expression resulting from a calculation.

For example,
3.141592653589793e+00x =
MATLAB will execute the above statement and return the following result:x = piformat long e

The format long e command allows displaying in exponential form with four decimal places plus the exponent.
For example,2.2922e+01ans =
MATLAB will execute the above statement and return the following result:4.678 * 4.9format short e

For example,
The format short e command allows displaying in exponential form with four decimal places plus the exponent.MATLAB displays large numbers using exponential notation.1064.70weekly_wage =

MATLAB will execute the above statement and return the following result:weekly_wage = daily_wage * 6daily_wage = 177.45;
format bank

2063/90ans =
MATLAB will execute the above statement and return the following result:4.678 * 4.9

Click Here To Watch Video..!

MATLAB Programming 7 - who command & clear command

Learn who command and clear command in MATLAB.

Click Here To Watch Video..!

MATLAB Programming 6 - Special Variables & Constants

Learn some special functions like ans, Inf, NaN, eps and commands like I and j..

Click Here To Watch Video..!

MATLAB Programming 5 - Basic functions used in metrix calculations

Learn basic functions used for matrix operations like functions for finding Eigen value, poly function, root function, whos function...

Click Here To Watch Video..!

Saturday, 21 May 2016

MATLAB Programming 4 - Basic metrix operations

In this section, let us discuss the following basic and commonly used matrix operations:

Addition and Subtraction of Matrices

Division of Matrices

Scalar Operations of Matrices

Transpose of a Matrix

Concatenating Matrices

Matrix Multiplication

Determinant of a Matrix

Inverse of a Matrix

Addition and Subtractions of matrix

Click Here To Watch Video..!

MATLAB Programming 3 - plotting graph

To plot the graph of a function, you need to take the following steps:

Define x, by specifying the range of values for the variable x, for which the function is to be plotted

Define the function, y = f(x)

Call the plot command, as plot(x, y)

Let us plot the simple function y = x for the range of values for x from 0 to 100, with an increment of 5.

Click Here To Watch Video..!

MATLAB Programming 2 - Metrix intro

MATLAB environment behaves like a super-complex calculator. You can enter commands at the >> command prompt.

MATLAB is an interpreted environment. In other words, you give a command and MATLAB executes it right away.

Hands on Practice

Type a valid expression, for example,
5 + 5
And press ENTER

When you click the Execute button, or type Ctrl+E, MATLAB executes it immediately and the result returned is:
ans = 10

Let us take up few more examples:
3 ^ 2 % 3 raised to the power of 2

When you click the Execute button, or type Ctrl+E, MATLAB executes it immediately and the result returned is:
ans = 9

Click Here To Watch Video..!

MATLAB Programming 1 - Introduction

MATLAB (matrix laboratory) is a fourth-generation high-level programming language and interactive environment for numerical computation, visualization and programming.
MATLAB is developed by MathWorks.

It allows matrix manipulations; plotting of functions and data; implementation of algorithms; creation of user interfaces; interfacing with programs written in other languages, including C, C++, Java, and FORTRAN; analyze data; develop algorithms; and create models and applications.

It has numerous built-in commands and math functions that help you in mathematical calculations, generating plots, and performing numerical methods.

Click Here To Watch Video..!