MATLAB (matrix laboratory) is a fourth-generation high-level
programming language and interactive environment for numerical
computation, visualization and programming.
পৃষ্ঠাসমূহ
Labels
Search Your Article
CS
Pageviews
Showing posts with label Matlab Tutorial. Show all posts
Showing posts with label Matlab Tutorial. Show all posts
Saturday, February 4, 2017
MATLAB - Environment Setup
Try it Option Online
You really do not need to set up your own environment to start learning MATLAB Octave. Reason is very simple, we already have set up MATLAB Octave environment online, so that you can execute all the available examples online at the same time when you are doing your theory work.
MATLAB - Basic Syntax
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.
MATLAB is an interpreted environment. In other words, you give a command and MATLAB executes it right away.
MATLAB - Variables
In MATLAB environment, every variable is an array or matrix.
You can assign variables in a simple way. For example,
You can assign variables in a simple way. For example,
x = 3 % defining x and initializing it with a valueMATLAB will execute the above statement and return the following result −
x = 3
MATLAB - 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.
In this section, we will provide lists of commonly used general MATLAB commands.
MATLAB - 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.
In previous chapters, you have learned how to enter commands from the MATLAB command prompt.
MATLAB - 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.
MATLAB - 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 −
MATLAB - 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.
MATLAB - 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 −
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 - 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.
MATLAB - Vectors
A vector is a one-dimensional array of numbers. MATLAB allows creating two types of vectors −
- Row vectors
- Column vectors
MATLAB - 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.
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.
MATLAB - 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 −
If you want to create a row vector, containing integers from 1 to 10, you write −
MATLAB - 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.
MATLAB - 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 - 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.
MATLAB - 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 −
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:
You can create the following type of files:
MATLAB - Plotting
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)
Subscribe to:
Posts (Atom)