
Such a declaration lasts until you clear the assignment or assign a numerical value to that variable instead. The usual way to do symbolic calculations in MATLAB (to avoid having to keep writing such awkward expressions as sym('x') over and over) is to declare certain variables to be symbolic. That way you can always distinguish numerical from symbolic output. If you look carefully, you'll see that MATLAB indents its answer a few spaces when the answer is numerical (double-precision) and indents it a lot when the answer is symbolic. So now when we take the sine, we get the exact answer 0. (which MATLAB denotes simply by pi) but to the exact number. So sym('pi') refers not to the approximate number 3.14159265. The command sym takes a string as an argument and tells MATLAB to interpret this string as a symbolic expression. You should see: sin(sym( 'pi'))Ī string of characters, enclosed in single quotes, is what MATLAB calls a string. For example, notice what happens if you type sin(sym('pi')) and hit Enter. It can also do exact, i.e., symbolic, calculations and algebra, using an accessory called the Symbolic Toolbox, but only if you tell it to. It is important to remember that MATLAB, by default, does numerical calculations with double-precision numbers.

The basic operations and functions are represented by * for "times", / for "divided by", ^ for powers (e.g., 3^3 means "3 cubed"), abs for absolute value, sqrt for square root, exp for the exponential function to the base e, so exp(1)=2.718281828., log for the logarithm function to the base e (often denoted ln), sin, cos, and tan for the basic trig functions, cosh, sinh, tanh for the basic hyperbolic functions, and asin, acos, atan for the inverse trig functions. ExerciseĮxperiment with using the MATLAB Command Window as a calculator. Thereafter, MATLAB will print out 15 significant digits (unless you go back to the default by typing format short). The MATLAB default is to print five digits, but you can change this by typing format long and hitting Enter. This is because MATLAB does arithmetic with double-precision numbers, which are only accurate to 15 places. Of course, but MATLAB gave the numerical answer (in scientific notation). MATLAB recognizes sin as the sine function and pi as the number.

MATLAB should type in response something like: ans = 1.2246e-016 In this way you can use MATLAB as a calculator. Position your mouse there and typeĪnd hit Enter. In the command window you should see a prompt that looks like >. In the toolbar, change the Current Directory to the directory or folder where you want to save your work.
#PUBLISH TAB IN MATLAB 2012 WINDOWS#
(The function of the other windows is explained in Chapter 3 of A Guide to MATLAB® for Beginners and Experienced Users, second edition, by Hunt, Lipsman and Rosenberg, which is on the reference shelf in the Mathematics Library.) You should see the MATLAB Desktop which includes several windows, the most important of which is the MATLAB Command Window.
