{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Variables" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. Must start with a letter, can have a combination of letters/numbers\n", "2. Case sensitive\n", "3. The format can be changed:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**format** — change the number/variable format" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x =\n", "\n", " 3.1416\n" ] } ], "source": [ "% some formats: short (default), short e, long, long e, bank\n", "x = pi;\n", "format short % default format\n", "x" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x =\n", "\n", " 3.1416e+00\n" ] } ], "source": [ "format short e % scientific notation, short\n", "x" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x =\n", "\n", " 3.141592653589793\n" ] } ], "source": [ "format long % much more precision\n", "x" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x =\n", "\n", " 3.141592653589793e+00\n" ] } ], "source": [ "format long e\n", "x" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x =\n", "\n", " 3.14\n" ] } ], "source": [ "format bank % two decimals, currency\n", "x\n", "format short % back to default" ] } ], "metadata": { "kernelspec": { "display_name": "Matlab", "language": "matlab", "name": "matlab" }, "language_info": { "codemirror_mode": "octave", "file_extension": ".m", "help_links": [ { "text": "MetaKernel Magics", "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" } ], "mimetype": "text/x-matlab", "name": "matlab", "version": "0.8.0" } }, "nbformat": 4, "nbformat_minor": 0 }