Category: 08. Matlab
-
Data Output
Data export (or output) in MATLAB means to write into files. MATLAB allows you to use your data in another application that reads ASCII files. For this, MATLAB provides several data export options. You can create the following type of files − Apart from this, you can also export data to spreadsheets. There are two…
-
Data Import
Importing data in MATLAB means loading data from an external file. The importdata function allows loading various data files of different formats. It has the following five forms − Sr.No. Function & Description 1 A = importdata(filename)Loads data into array A from the file denoted by filename. 2 A = importdata(‘-pastespecial’)Loads data from the system clipboard rather than…
-
Functions
A function is a group of statements that together perform a task. In MATLAB, functions are defined in separate files. The name of the file and of the function should be the same. Functions operate on variables within their own workspace, which is also called the local workspace, separate from the workspace you access at the…
-
Strings
Creating a character string is quite simple in MATLAB. In fact, we have used it many times. For example, you type the following in the command prompt − MATLAB will execute the above statement and return the following result − MATLAB considers all variables as arrays, and strings are considered as character arrays. Let us…
-
Numbers
MATLAB supports various numeric classes that include signed and unsigned integers and single-precision and double-precision floating-point numbers. By default, MATLAB stores all numeric values as double-precision floating point numbers. You can choose to store any number or array of numbers as integers or as single-precision numbers. All numeric types support basic array operations and mathematical…
-
Colon Notation
The colon(:) is one of the most useful operator in MATLAB. It is used to create vectors, subscript arrays, and specify for iterations. If you want to create a row vector, containing integers from 1 to 10, you write − MATLAB executes the statement and returns a row vector containing the integers from 1 to 10 − If…
-
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…