0% found this document useful (0 votes)
16 views2 pages

Overview of MATLAB Variables: Scalars Vectors Matrices Strings

The document provides an overview of the key topics to be covered in a 2 hour MATLAB lab lecture, including: 1. Creating, modifying, and deleting variables 2. Creating and running MATLAB script files 3. Creating and using inline functions for computation 4. An overview of plotting in MATLAB It also provides details on MATLAB variables, including how they are created using an assignment operator, that variable names are case sensitive, and that MATLAB treats all numerical variables as matrices internally even if they represent a scalar or vector value.

Uploaded by

shamsukarim2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Overview of MATLAB Variables: Scalars Vectors Matrices Strings

The document provides an overview of the key topics to be covered in a 2 hour MATLAB lab lecture, including: 1. Creating, modifying, and deleting variables 2. Creating and running MATLAB script files 3. Creating and using inline functions for computation 4. An overview of plotting in MATLAB It also provides details on MATLAB variables, including how they are created using an assignment operator, that variable names are case sensitive, and that MATLAB treats all numerical variables as matrices internally even if they represent a scalar or vector value.

Uploaded by

shamsukarim2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

LAB LECTURE 1

VARIABLES DECLARATION, SCRIPTS, VECTORS, FUNCTION, PLOTS IN MATLAB

Lesson Outcomes

At this end of the 2 hours lab, the students are expected to the abilities on:
Variables
1. Creating the suitable variables and assigning it with data
2. Modifying the existing variables with new data
3. Delete the variable from MATLAB memory

Script
1. Create a script MATLAB file (m-file) using command or MATLAB menus
2. Run the m-file

Function
1. Create an inline function to store the required function for computatation
2. Run the inline function
Plotting

Overview of MATLAB Variables


This section describes the fundamental operations involved in the creation and use
of MATLAB variables. Detailed discussions of scalars, vectors, matrices,
and strings are provided in separate sections.
MATLAB variables are created when they appear on the left of an equal sign. The
generic statement
>> variable = expression

creates the ``variable'' and assigns to it the value of the expression on the right
hand side. You do not need to define or declare a variable before it is used.
Matrices do not need to explicitly dimensioned, and MATLAB allows you to
increase the size of a matrix as you work.

Advanced MATLAB users will point out that the speed of MATLAB functions can
be increased by pre-allocating memory for matrices and vectors. This and other
performance considerations are discussed elsewhere.
Variable names must begin with an alphanumeric letter. Following that, any
number of letters, digits and underscores can be added, but only the first 19
characters are retained. MATLAB variable names are case sensitive so x and X are
different variables.
All numerical variables in MATLAB are matrices, a mathematical data type
corresponding to a two-dimensional array of numbers. Before performing any
calculations with a numeric variable, MATLAB prods and pokes into its contents.
MATLAB is very careful to follow the rigorous rules of linear algebra, and it only
allows legal operations between matrices, vectors and scalars.
But what about the statement that ``all numerical variables in MATLAB are
matrices''?
MATLAB keeps track of the dimension of each variable. Thus, the statement

You might also like