O'Reilly logo

Computational Intelligence: Synergies of Fuzzy Logic, Neural Networks and Evolutionary Computing by Hojjat Adeli, Nazmul Siddique

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix A

MATLAB® Basics

A.1.1 Variables

The prompt (>>) in the command window indicates that MATLAB® is ready to accept input. A variable (x or a) is entered at the prompt and MATLAB® responds in the following way:

>> x=2.66
x =
   2.6600
 
>> a=x+0.0099
a =
   2.6699

Numerical output is suppressed by putting a semicolon (;) at the end of the line. For example:

>> x=2.66;
>> x=x+0.33
x =
 2.9900

A.1.2 Input and Output Commands

MATLAB® supports simple input/output commands. The command ‘input’ can be used for assigning values to variables. The general form of use is shown as follows:

variable = input('prompt')

The command displays the prompt as a message to the user on the screen, waits for input from the keyboard and returns the value entered in the variable. The response to the input prompt can be any MATLAB® expression, which is evaluated using the variables in the current workspace. For example:

>> x = input('Enter x: ')
Enter x: 5
x =
   5

>> y = input('Enter y: ')
Enter y: x+2
y =
   7

The input command can also be used to assign a string to a variable. The general form of use is shown as follows:

variable = input('prompt', 's')

The command returns the entered string as a text variable rather than as a variable name or numerical value. For example:

>> val = input('Enter y/n: ', 's')
Enter y/n: y
val =
    y

MATLAB® automatically generates a display when commands are executed. In addition to this automatic display, MATLAB® has several commands that can be used to generate displays ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required