Interacting & Saving VariablesΒΆ

  • One way to think about and use Matlab is as a very powerful calculator

  • You can enter mathematical operations directly into the command window and press enter to get an answer

    For example:

    _images/basic1.png

  • You can save any value(s) as a variable in Matlab. First type the name of the variable that you wish to describe followed by an equals sign. After the equals sign, write the expression that you wish to be saved. The expression can be as simple as a number or as complicated as you like. The size of the saved variable will be limited by your computers available memory.

  • Another way to think about this is simply to say that what is on the left hand side of the equals sign is the variable name, and what is on the right hand side of the equals sign is the value(s) to be named.
_images/savevariable.png

  • Matlab saves the created variables and allows you to access them by either simply typing their name and enter in the command window, or by double clicking on them in the Workspace

  • Once the variables are saved, the user can interact the variables by using mathematical expressions to create new variables

For example:

_images/savevariable2.png
  • The user can also update or modify existing variables by including the variable name on both sides of the equals sign. Setting a variable equal to a new value after it has already been assigned a value has the same effect of clearing Matlab’s memory of the variable and assigning it a new value.

For example:

_images/savevariable3.png