Author: admin
-
Arrays
All variables of all data types in MATLAB are multidimensional arrays. A vector is a one-dimensional array and a matrix is a two-dimensional array. We have already discussed vectors and matrices. In this chapter, we will discuss multidimensional arrays. However, before that, let us discuss some special types of arrays. Special Arrays in MATLAB In…
-
Matrix
A matrix is a two-dimensional array of numbers. In MATLAB, you create a matrix by entering elements in each row as comma or space delimited numbers and using semicolons to mark the end of each row. For example, let us create a 4-by-5 matrix a − MATLAB will execute the above statement and return the following result…
-
Vectors
A vector is a one-dimensional array of numbers. MATLAB allows creating two types of vectors − Row Vectors Row vectors are created by enclosing the set of elements in square brackets, using space or comma to delimit the elements. MATLAB will execute the above statement and return the following result − Column Vectors Column vectors are created…
-
Loop Types
There may be a situation when you need to execute a block of code several number of times. In general, statements are executed sequentially. The first statement in a function is executed first, followed by the second, and so on. Programming languages provide various control structures that allow for more complicated execution paths. A loop…
-
Decision Making
Decision making structures require that the programmer should specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false. Following is…
-
Operators
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. MATLAB is designed to operate primarily on whole matrices and arrays. Therefore, operators in MATLAB work both on scalar and non-scalar data. MATLAB allows the following types of elementary operations − Arithmetic Operators MATLAB allows two different types of…
-
Data Types
MATLAB does not require any type declaration or dimension statements. Whenever MATLAB encounters a new variable name, it creates the variable and allocates appropriate memory space. If the variable already exists, then MATLAB replaces the original content with new content and allocates new storage space, where necessary. For example, The above statement creates a 1-by-1…
-
M-Files
So far, we have used MATLAB environment as a calculator. However, MATLAB is also a powerful programming language, as well as an interactive computational environment. In previous chapters, you have learned how to enter commands from the MATLAB command prompt. MATLAB also allows you to write series of commands into a file and execute the…
-
Commands
MATLAB is an interactive program for numerical computation and data visualization. You can enter a command by typing it at the MATLAB prompt ‘>>’ on the Command Window. In this section, we will provide lists of commonly used general MATLAB commands. Commands for Managing a Session MATLAB provides various commands for managing a session. The following…
-
Variables
In MATLAB environment, every variable is an array or matrix. You can assign variables in a simple way. For example, MATLAB will execute the above statement and return the following result − It creates a 1-by-1 matrix named x and stores the value 3 in its element. Let us check another example, MATLAB will execute the above…