Experiment No.5 Starting With MATLAB Program
Experiment No.5 Starting With MATLAB Program
Introduction:
MATLAB® (MATrix LABoratory) is a high-level language and interactive environment for
numerical computation, visualization, and programming. Using MATLAB, you can analyze data,
develop algorithms, and create models and applications. The language, tools, and built-in math
functions enable you to explore multiple approaches and reach a solution faster than with
spreadsheets or traditional programming languages, such as C/C++ or Java®. You can use
MATLAB for a range of applications, including signal processing and communications, image
and video processing, control systems, test and measurement, computational finance, and
computational biology. More than a million engineers and scientists in industry and academia
use MATLAB, the language of technical computing.
1. Command window.
2. Figure window : this window only pops up whenever you plot something.
3. Editor window: This window is used for writing and editing MATLAB programs (called
M-files) and can be invoked in Windows from the pull-down menu after selecting File |
New | M-file
1- Generating Vectors and the Colon Notation: We can create a 1D vector directly as
1- Row Vector : for example
>> a= [1 2 3]
a=
1 2 3
2- Column Vector : for example
We could also from a vector by using the colon (: ) operator. “Colon Notation " is used to
generate vectors and to reference sub matrices. The colon notation and subscripting by
integral vectors and keys to efficient manipulation in MATLAB. Creative use of these
features to factorize operations lets you minimize the use of loops (which slows MATLAB
down) and makes code simple and readable
We could also use any increment to construct matrices (The increment put in the middle)
The colon notation can be used to access submatrices of a matrix. For example:
p(1:2,3) is the column vector consisting of the first 2 entries of the 3rd column of matrix p.
3- Deleting Rows and Columns: You can delete rows and columns from a matrix using just a
pair of square brackets. Start with
4- Matrix Division
5- Entry-Wise Operations:
1-For:
2- While:
3- Branching (If):
4- Switch:
9- Plotting:
1- Basic Two-Dimensional Plot:
2-
4-
Report:
1- what is the output of the following commands?
2-