MATLAB Variables

Introduction

1. Defined with assignment operator, “=”.
2. Can be assigned without declaring their type and their type can change.
3. Values can come from constants, computation involving values of other variables, or from the output of a function.
4. Note that MATLAB is case sensitive! The variables x and X are not the same.                                                                   5. Semicolon is used to suppress the output of the line that it concludes and not to terminate commands.

Built-in Commands

 

Naming a variable uniquely

1. To avoid choosing a name for a new variable that might conflict with a name already in use, check for any occurrences of the name using the which command. Format: which -all variable_name

2. The iskeyword command is also used to list all reserved names.


3. These reserved names can’t be assigned to any variable(s).
4. If anyone accidentally assign any of these names, use clear
command to reset it back to normal.

Task: Basic Operation

Type following commands in command window:
>>y=16;
>>z=3
1. When semicolon is used, no output will be displayed.
2. Some functions display output even if semicolon is used, like disp, plot, etc

Built-in Functions

To read more about these functions, use “help” command.

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s