<< Chapter < Page Chapter >> Page >
This module is part of the collection, A First Course in Electrical and Computer Engineering . The LaTeX source files for this collection were created using an optical character recognition technology, and because of this process there may be more errors than usual. Please contact us if you discover any errors.

Any result you wish to keep for a while may be assigned to a variable other than: ans

A semicolon (;) at the end of the line suppresses printing of the result, as when we calculated y in the next-to-last line just shown. This feature is especially useful when writing MATLAB programs where intermediate results are notof interest and when working with large matrices.

MATLAB supports the dynamic creation of variables. You can create your own variables by just assigning a value to a variable. For example, type. Then the real variablecontains the value. Variable names must start with an alphabetical character and be less than nineteen characterslong. If you type, the contentis replaced by the value. Some commands allow you to keep track of all the variables that you havealready created in your session. Typeorto get the list and names of the variables currently in memory (gives more information than). To clear all the variables, type in. To clear a single variable (or several) from the list, follow the commandby the name of the variable you want to delete or by a list of variable names separated by spaces. Try it now. clear

MATLAB is case sensitive. In other words, x and X are two different variables. You can control the case sensitivity of MATLAB by entering the command, which toggles the sensitivity. The commandon enforces case sensitivity, andcancels it. casesen off

If one line is not enough to enter your command, then finish the first line with two dots ( . . ) and continue on the next line. You can enter more than one command per line by separating them with commas if you want the result displayed or with semicolons if you do not want the result displayed. For example, type

to first compute,, andand then to print x and y . sin(theta)

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, A first course in electrical and computer engineering. OpenStax CNX. Sep 14, 2009 Download for free at http://cnx.org/content/col10685/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'A first course in electrical and computer engineering' conversation and receive update notifications?

Ask