learnonline

MATLAB Short Course

2. Simple Mathematics

Assignment statements.

The preceding MATLAB commands that assign the value of the expression after the ’=’ sign  to the variable before the ’=’ sign are assignment statements. Note that all variables in the expression after the ’=’ sign must have previously been allocated a value, or else an error occurs. For example, enter the following commands:

c=sqrt(a^2+b^2)

You will see the error message ??? Undefined function or variable ’b’ .  Consider the following:

The last line has nothing at all to do with a mathematical equation. It is a MATLAB  assignment statement that calculates x 2 −12 at x = 7 and stores the result in the variable x , thereby over-writing the previous value.

Browse Course Material

Course info.

  • Yossi Farjoun

Departments

  • Mathematics

As Taught In

  • Programming Languages
  • Computational Modeling and Simulation
  • Applied Mathematics

Learning Resource Types

Introduction to matlab programming.

Often, a result of some calculation is needed for later use, or perhaps a complicated expression can be examined more carefully if done in parts. Both can be done by the use of “variables”. Variables hold whatever result you put in them by the use of the equal sign ( = ):

  • x=1 creates a variable called “x” and stores the value “1” in it. If one then types “x” in an expression , MATLAB® will use the value stored in “x”, i.e., “1”.
  • Similarly one can define variables to hold anything that MATLAB can calculate.
  • You can easily overwrite a variable with a new assignment: x=2 now the variable x “contains” the value “2”.
  • One can use x as part of an expression: x^2+x-cos(x)
  • Or to create a new variable: y= x^2+7
  • A variable can be a vector (or matrix): A= [1 2 3 4]
  • One can change just a part of A : A(3)= 0

In this last example, we are getting ahead of ourselves by referring to an element of a vector. We will touch on that more later.

Note that you can “hide” important MATLAB functions and constants by defining a variable with the same name: pi=3 will give interesting results later (to remove clear pi ). This is usually not a good idea, so take care before using a nice name like sum , exp , or det , as these are all built-in functions. You can check if a variable is already in use by using the which command:

tells us that pi is a built-in function, while

tells us that Pi is unused. The difference is in the capitalization. MATLAB-defined functions will always use lower-case names (even if the helpfile will show these as all CAPITAL), which implies that you can always avoid collision by capitalizing the fiirst letter of your variable and functions names.

  • Let x=1 and y=2 . Exchange the values of these two variables without specif­ically using ‘1’ or ‘2’ i.e., the exchange should work regardless of the values held by the variables. Hint: You can invent a new variable. Another Hint: Imagine you have misplaced your kids’ breakfast and now Tom’s Cornflakes are in Sally’s bowl and Sally’s CocoPuffs are in Tom’s bowl. You have already poured the milk, how can you fix the problem without throwing away and starting over?
  • Repeat some of the previous exercises using variables.

facebook

You are leaving MIT OpenCourseWare

Library homepage

  • school Campus Bookshelves
  • menu_book Bookshelves
  • perm_media Learning Objects
  • login Login
  • how_to_reg Request Instructor Account
  • hub Instructor Commons

Margin Size

  • Download Page (PDF)
  • Download Full Book (PDF)
  • Periodic Table
  • Physics Constants
  • Scientific Calculator
  • Reference & Cite
  • Tools expand_more
  • Readability

selected template will load here

This action is not available.

Engineering LibreTexts

1.4.1: More About Valid Variable Names

  • Last updated
  • Save as PDF
  • Page ID 87272

  • Carey Smith
  • Oxnard College

\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

\( \newcommand{\Span}{\mathrm{span}}\)

\( \newcommand{\id}{\mathrm{id}}\)

\( \newcommand{\kernel}{\mathrm{null}\,}\)

\( \newcommand{\range}{\mathrm{range}\,}\)

\( \newcommand{\RealPart}{\mathrm{Re}}\)

\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

\( \newcommand{\Argument}{\mathrm{Arg}}\)

\( \newcommand{\norm}[1]{\| #1 \|}\)

\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

\( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

\( \newcommand{\vectorC}[1]{\textbf{#1}} \)

\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

Variable Name Rules

MATLAB variable names must start with a letter. The rest of the name can be letters, numbers or the underscore symbol. The letters can be upper or lower case. These are valid variable names:

b, B, Basketball, Basket_Ball, basket5ball, basketBall_12345

These are not valid names:

Basket-Ball, Basket_Ball!, Basket?Ball, Basket Ball.

Descriptive names are encouraged, in order to make the code readable. So 'pressure' and 'press' are better names than just 'p'. Names are allowed to be very long, but they should not be more than a quarter of the command window, so keep them to less than 20 letters, unless there is a very good reason to make them longer. (The maximumn allowed name length is 63 characters.)

Sometimes, you may have 2 version of the same quantity, such as a distance in both inches and centimeters. A good practice is to give them related names with identifiers, such as dist_inch and dist_cm, so that you always know which units you are using.

Variable Names to Avoid

Don't use the name of a function. For example, don't use these names:

sqrt, sin, cos, log10, sum.

Also, don't use 2 names that only differ for upper vs. lower case letters; that can lead to confusion. For example, having 2 variables named kg and Kg should be avoided.

Exercise \(\PageIndex{1}\) Good Variable Names

Which of the following are good variable names? Make a decision about each before looking at the answers.

You may enter each in the command window by setting the name = 1, in order to see if it is valid.

You may use the exist() function to see if it is a function name.

A-very_long_name

Even_123_longer456_name_9876543210

sind -- a function name--don't use it

sinx -- valid

A-very_long_name -- not valid becuz of the -, which is interpreted as a minus sign

Even_123_longer456_name_9876543210 -- valid

important! -- nor valid becuz of the !

_next -- not valid. It can't start with an underscore

1one1 -- not valid. It can't start with a number

MATLAB keywords

It is not allowed to use MATLAB keywords. These are words that MATLAB reserves for program structure. This is the list of keywords:

'break' 'case' 'catch' 'classdef' 'continue' 'else' 'elseif' 'end' 'for' 'function' 'global' 'if' 'otherwise' 'parfor' 'persistent' 'return' 'spmd' 'switch' 'try' 'while'

MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] by Raj Kumar Bansal, Ashok Kumar Goel, Manoj Kumar Sharma

Get full access to MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] and 60K+ other titles, with a free 10-day trial of O'Reilly.

There are also live events, courses curated by job role, and more.

2.8. Assignment Statement

General form of an assignment statement is given as follows:

When an assignment statement is executed, the value of the expression to the right of the equality sign is first computed and the result obtained is assigned to the variable mentioned on the left of the equality sign.

Example 2.5.

Get MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.

Don’t leave empty-handed

Get Mark Richards’s Software Architecture Patterns ebook to better understand how to design components—and how they should interact.

It’s yours, free.

Cover of Software Architecture Patterns

Check it out now on O’Reilly

Dive in for free with a 10-day trial of the O’Reilly learning platform—then explore all the other resources our members count on to build skills and solve problems every day.

variable assignment statement matlab

Help Center Help Center

  • Help Center
  • Mises à jour du produit
  • Documentation

Create and Edit Variables

Create variables.

The MATLAB ® workspace consists of the variables you create and store in memory during a MATLAB session. You can create new variables in the workspace by running MATLAB code or using existing variables.

To create a new variable, enter the variable name in the Command Window, followed by an equal sign ( = ) and the value you want to assign to the variable. For example, if you run these statements, MATLAB adds the four variables x , A , I , and C to the workspace:

Workspace browser showing all four variables

You do not have to declare variables before assigning values to them.

If you do not end the assignment statement with a semicolon ( ; ), MATLAB displays the result in the Command Window. For example,

If you do not explicitly assign the output of a statement to a variable, MATLAB generally assigns the result to the reserved word ans . The value of ans changes with every statement that returns an output value that is not assigned to a variable. For example,

To view and edit variables, use the Workspace browser and Variables editor. (Some editing options are not available in MATLAB Online™ .)

View Workspace Contents

To view a list of variables in your workspace, use the Workspace browser.

To open the Workspace browser if it is not currently visible, do either of the following:

On the Home tab, in the Environment section, click Layout . Then, under Show , select Workspace .

Type workspace in the Command Window.

By default, the Workspace browser displays the base workspace. You also can view function workspaces if MATLAB is in debug mode. For more information, see Base and Function Workspaces .

variable assignment statement matlab

You also can use the who command in the Command Window to view a list of variables. To list information about size and class, use the whos command. For example, if you have the variables x , A , and I in your workspace, you can run the who and whos commands to view your workspace contents: who Your variables are: A C I x whos Name Size Bytes Class Attributes A 3x3 72 double C 1x3 528 cell I 3x3 72 double x 1x1 8 double

View Variable Contents

You can view the contents of a variable in several ways:

Command Window — Type the variable name at the command prompt. For example: x x = 5.7100

Variables editor — In the Workspace browser, double-click a variable name. The Variables editor opens for that variable.

Variables editor showing C

Some variables open a viewer or other tool appropriate for their type. For details, see the documentation for that data or object type.

variable assignment statement matlab

To change how the Variables editor displays variables, go to the View tab, and in the Format section, select a number display format. The display format does not affect how values are displayed in the Command Window or Workspace browser, or how the variables are saved.

The maximum number of elements in a variable that you can open in the Variables editor depends on your operating system and the amount of physical memory installed on your system.

Edit Variable Contents

You can edit the contents of scalar (1-by-1) variables in the Workspace browser. To edit the contents, click the variable value to select it and then enter a new value.

To edit other variables, open them in the Variables editor. For example, suppose that you create a cell array, C , by running these commands in the Command Window: A = magic(4); C = {A A A}; In the Workspace browser, double-click the variable name C to open it in the Variables editor.

To edit an element of a variable, double-click the element. The element opens in a new document within the Variables editor. For example, if you double-click element C{1,1} in the Variables editor, the contents of that cell open in a new tab. You can edit the value of a variable element by clicking the element and typing a new value. Press Enter or click another element to save the change.

Variables editor showing C{1,1}

To return to the parent cell array or structure of an element, go to the View tab and click the Go Up button.

Changes you make in the Variables editor are automatically saved in the workspace. Changes you make to variables via the Command Window or other operations automatically update the information for those variables in the Workspace browser and Variables editor.

You cannot edit elements or subsets of multidimensional arrays in the Variables editor.

You cannot edit tall arrays in the Variables editor.

When editing strings in the Workspace browser or as part of a structure in the Variables editor, you must use double quotes to surround the string value.

Edit Table and Structure Array Variables

Tables (including timetables) and structure arrays support additional editing actions.

The contents of a table are only visible and modifiable when the number of variables is fewer than 5000. When the number of variables equals or exceeds 5000, you can only view the table properties.

Changes made to certain variable types in the Variables editor also appear in the Command Window. For example, suppose you have a table T that contains three columns, A , B , and C . If you delete column A in the Variables editor, the line T(:,'A') = []; displays in the Command Window. To suppress code display in the Command Window, on the View tab, clear the Show MATLAB Code check box.

Resize or Reshape Variables

To modify the size, shape, and order of variable elements in the Variable editor, use one of these procedures.

Empty Elements

Empty elements in variables are assigned default values. Default assignments are:

0 for numeric arrays

[] for cell arrays and structure arrays

<undefined> for categorical variables

Copy, Rename, and Delete Variables

You can copy and paste, duplicate, rename, and delete variables within the Workspace browser.

To create a new workspace variable from an existing variable, in the Variables editor, select an element, data range, row, or column in an array, and then in the Variable tab, select New from Selection .

You can change the character that delimits decimals in the data when you cut and paste values from the Variables editor into text files or other applications. You might do this, for instance, if you provide data to a locale that uses a character other than the period ( . ). To change the delimiter character, specify a Decimal separator for exporting numeric data via system clipboard in the Variables Preferences .

Navigate Variable Contents

When editing variables in the Variables editor, some variables can contain large amounts of data, making it difficult to navigate between elements. Use these keyboard shortcuts to move easily between variable elements in the Variables editor. You cannot modify these keyboard shortcuts.

openvar | Workspace Browser

Related Topics

  • Variable Names
  • Display Statistics in the Workspace Browser
  • Workspace and Variable Preferences
  • Save and Load Workspace Variables

Commande MATLAB

Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :

Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

  • Switzerland (English)
  • Switzerland (Deutsch)
  • Switzerland (Français)
  • 中国 (English)

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

  • América Latina (Español)
  • Canada (English)
  • United States (English)
  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)

Contact your local office

Help Center Help Center

  • Help Center
  • Trial Software
  • Product Updates
  • Documentation

if , elseif , else

Execute statements if condition is true

Description

if expression , statements , end evaluates an expression , and executes a group of statements when the expression is true. An expression is true when its result is nonempty and contains only nonzero elements (logical or real numeric). Otherwise, the expression is false.

The elseif and else blocks are optional. The statements execute only if previous expressions in the if...end block are false. An if block can include multiple elseif blocks.

collapse all

Use if, elseif, and else for Conditional Assignment

Create a matrix of 1s.

Loop through the matrix and assign each element a new value. Assign 2 on the main diagonal, -1 on the adjacent diagonals, and 0 everywhere else.

Compare Arrays

Expressions that include relational operators on arrays, such as A > 0 , are true only when every element in the result is nonzero.

Test if any results are true using the any function.

Test Arrays for Equality

Compare arrays using isequal rather than the == operator to test for equality, because == results in an error when the arrays are different sizes.

Create two arrays.

If size(A) and size(B) are the same, concatenate the arrays; otherwise, display a warning and return an empty array.

Compare Character Vectors

Use strcmp to compare character vectors. Using == to test for equality results in an error when the character vectors are different sizes.

Test Values for Inequality

Determine if a value is nonzero. Use the ~= operator to test for inequality.

Evaluate Multiple Conditions in Expression

Determine if a value falls within a specified range.

An expression can include relational operators (such as < or == ) and logical operators (such as && , || , or ~ ). Use the logical operators and and or to create compound expressions. MATLAB ® evaluates compound expressions from left to right, adhering to operator precedence rules.

Within the conditional expression of an if...end block, logical operators & and | behave as short-circuit operators. This behavior is the same as && and || , respectively. Since && and || consistently short-circuit in conditional expressions and statements, it is good practice to use && and || instead of & and | within the expression. For example,

The first part of the expression evaluates to false. Therefore, MATLAB does not need to evaluate the second part of the expression, which would result in an undefined function error.

You can nest any number of if statements. Each if statement requires an end keyword.

Avoid adding a space after else within the elseif keyword ( else if ). The space creates a nested if statement that requires its own end keyword.

Extended Capabilities

C/c++ code generation generate c and c++ code using matlab® coder™., hdl code generation generate vhdl, verilog and systemverilog code for fpga and asic designs using hdl coder™..

Do not use the & and | operators within conditions of an if statement. Instead, use the && and || operators.

HDL Coder™ does not support nonscalar expressions in the conditions of if statements. Instead, use the all or any functions to collapse logical vectors into scalars.

Thread-Based Environment Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool .

This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment .

Version History

Introduced before R2006a

for | while | switch | return

  • Operators and Elementary Operations

External Websites

  • Fundamentals of Programming (MathWorks Teaching Resources)

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

  • Switzerland (English)
  • Switzerland (Deutsch)
  • Switzerland (Français)
  • 中国 (English)

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

  • América Latina (Español)
  • Canada (English)
  • United States (English)
  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)

Contact your local office

IMAGES

  1. [Best answer]-How to use functions to assign variables in MATLAB?

    variable assignment statement matlab

  2. MATLAB Variable (Assign value, string Display, multiple Variables & Rules)

    variable assignment statement matlab

  3. Variables in MATLAB Command Window

    variable assignment statement matlab

  4. Matlab Variables

    variable assignment statement matlab

  5. Declaration of Variables in MATLAB

    variable assignment statement matlab

  6. How Matlab Assignment Operator Works (Example)

    variable assignment statement matlab

VIDEO

  1. _DSDV_Discuss Structure, Variable Assignment Statement in verilog

  2. 6 storing values in variable, assignment statement

  3. Zero to One

  4. How to declare variable in Matlab in Urdu Hindi Tutorial 3

  5. Lecture-8: Initializing variables in MATLAB part 1 (Hindi/Urdu)

  6. Session 31; MID and Finals on for... end statement; MATLAB

COMMENTS

  1. Assign value to variable in specified workspace

    To assign values in the MATLAB base workspace, use 'base'. The base workspace stores variables that you create at the MATLAB command prompt, including any variables that scripts create, assuming that you run the script from the command line or from the Editor. To assign variables in the workspace of the caller function, use 'caller'. The caller ...

  2. Create and Edit Variables

    You can create new variables in the workspace by running MATLAB code or using existing variables. To create a new variable, enter the variable name in the Command Window, followed by an equal sign (=) and the value you want to assign to the variable. For example, if you run these statements, MATLAB adds the four variables x, A, I, and C to the ...

  3. 1.4: Variables and Assignment Statements

    Assignment Statements. You can create your own variables, and give them values, with an assignment statement. The assignment operator is the equals sign (=), used like so: >> x = 6 * 7 x = 42. This example creates a new variable named x and assigns it the value of the expression 6 * 7. MATLAB responds with the variable name and the computed value.

  4. Comma-Separated Lists

    You can assign any or all consecutive elements of a comma-separated list to variables with a simple assignment statement. Define the cell array Cand assign the first row to variables c1 through c6. C = cell ... MATLAB assigns C{1,1:3} to the variables c1, c2, and c3 and ignores C{1,4:6}.

  5. MATLAB: Assignment statements

    The preceding MATLAB commands that assign the value of the expression after the '=' sign to the variable before the '=' sign are assignment statements. ... It is a MATLAB assignment statement that calculates x 2 −12 at x = 7 and stores the result in the variable x, thereby over-writing the previous value. Previous.

  6. Assignment vs Equality

    Assignment Statement. An assignment statement is used to assign a value to a variable name. Once the value has been assigned, the variable name can be used instead of the value. Matlab allows a variable to be assigned to a single scalar value, or an array of values. You will learn more about arrays in later lessons. The = sign is the assignment ...

  7. 2.1 Variable assignment in MATLAB

    This video explains the definition of variable assignment in MATLAB and what is the rules to name a variable in MATLAB. In addition, How to defined multiple ...

  8. Variables

    If one then types "x" in an expression, MATLAB® will use the value stored in "x", i.e., "1". Similarly one can define variables to hold anything that MATLAB can calculate. You can easily overwrite a variable with a new assignment: x=2 now the variable x "contains" the value "2". One can use x as part of an expression: x^2+x ...

  9. MATLAB Variable (Assign value, string Display, multiple Variables & Rules)

    In MATLAB, an assignment statement automatically generates variable. Assign the value to a Variable. An assignment statement used for assigning a value to a variable. The assignment statement generally having the symbol = which is known as the assignment operator. Example: The statement in MATLAB is given as. x=10; fprintf('%d\n',x) Output: 10 ...

  10. Variable Assignment

    Variable Assignment. This works just like storing values as variables on your calculator, except it is much easier with MATLAB (and a full keyboard). >> x = 42. x =. 42. We say that the variable x has been assigned the value 42, or that the value 42 is now "stored in x ". Notice that a new entry has appeared in the workspace corresponding to ...

  11. Assign Multiple Variables

    Open in MATLAB Online. The thing we are trying to do is emulate the very useful Python idiom e.g. a,b,c,d = [1,2,3,4] In Matlab, if you create a function assignList.m as follows: Theme. Copy. function varargout = assignList ( inputArray ) for i = 1:length ( inputArray) varargout {i} = inputArray (i);

  12. matlab

    with assignin you can only assign-in 1 variable at once. With "who" you get a cell-array of strings, that contains the names of the variables. Now if you have this list: myVarList=who; you can loop over and assign the variables to the workspace:

  13. 1.4.1: More About Valid Variable Names

    Variable Name Rules. MATLAB variable names must start with a letter. The rest of the name can be letters, numbers or the underscore symbol. The letters can be upper or lower case. These are valid variable names: b, B, Basketball, Basket_Ball, basket5ball, basketBall_12345. These are not valid names:

  14. Assignment Statement

    2.8. Assignment Statement General form of an assignment statement is given as follows: variable_name = expression; When an assignment statement is executed, the value of the expression to the right … - Selection from MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] [Book]

  15. Conditional Statements

    Conditional Statements. Conditional statements enable you to select at run time which block of code to execute. The simplest conditional statement is an if statement. For example: % Generate a random number. a = randi(100, 1); % If it is even, divide by 2. if rem(a, 2) == 0. disp('a is even')

  16. Create and Edit Variables

    You can create new variables in the workspace by running MATLAB code or using existing variables. To create a new variable, enter the variable name in the Command Window, followed by an equal sign (=) and the value you want to assign to the variable. For example, if you run these statements, MATLAB adds the four variables x, A, I, and C to the ...

  17. Execute statements if condition is true

    Description. end evaluates an expression , and executes a group of statements when the expression is true. An expression is true when its result is nonempty and contains only nonzero elements (logical or real numeric). Otherwise, the expression is false. The elseif and else blocks are optional.