Practical 2: Variables, Script M-files and Graphing

Variables

What is valid?

 

> Type in the following examples exactly as written to see what is a <valid expression> and <variable name>.

> Check what happens in your Workspace Window when you create and update your variables.

x=1+4 Valid? Y/N Reason (if invalid)

x=1+2+...+10        Valid? Y/N Reason (if invalid)

x+1=7               Valid? Y/N Reason (if invalid)

x=2(6)              Valid? Y/N Reason (if invalid)

bigX=x+1            Valid? Y/N Reason (if invalid)

x=newX+1            Valid? Y/N Reason (if invalid)

x=x+1                Valid? Y/N Reason (if invalid)

 

The last example shows an important concept: a variable can refer to itself to be given a new value.

flow chart