This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
matlab_-_introduction [2012/10/06 04:09] jochen created |
matlab_-_introduction [2012/11/12 17:52] (current) jochen [Command line] |
||
---|---|---|---|
Line 8: | Line 8: | ||
===== Language features ===== | ===== Language features ===== | ||
* the language is easy to use for prototyping, given its forgiving and user-friendly nature | * the language is easy to use for prototyping, given its forgiving and user-friendly nature | ||
- | * variables do require a declaration and can be defined and have their datatype and dimension changed at any point within a program | + | * variables don't require a declaration but can be defined and have their datatype and dimension changed at any point within a program |
* numeric variables are, by default, all created with a standard datatype of **''double''**, requiring little (if any) knowledge of numeric datatypes | * numeric variables are, by default, all created with a standard datatype of **''double''**, requiring little (if any) knowledge of numeric datatypes | ||
- | * identifiers can be overloaded (e.g. built-in functions can be replaced by user defined ones) | + | * storage of and access to variable values is organized in workspaces |
+ | * identifiers can be overloaded (e.g. built-in functions can be replaced by user defined ones), globally or separately in each workspace | ||
* array indexing is available in multiple ways to simplify element selection (see [[Matlab - datatypes|datatypes and indexing page]]) | * array indexing is available in multiple ways to simplify element selection (see [[Matlab - datatypes|datatypes and indexing page]]) | ||
* array-based operations are highly optimized for speed and mostly support multiple CPU cores | * array-based operations are highly optimized for speed and mostly support multiple CPU cores | ||
- | * memory management is built-in (garbage collection on variables no longer in use) | + | * memory management is built-in (workspace-related garbage collection on variables no longer in use) |
* Matlab comes with a vast repository of built-in and built-upon functions for mathematical computations, data in- and output, as well as visualization | * Matlab comes with a vast repository of built-in and built-upon functions for mathematical computations, data in- and output, as well as visualization | ||
* functions can return more than one output value/variable (without having to resort to compound/struct variables) | * functions can return more than one output value/variable (without having to resort to compound/struct variables) | ||
Line 20: | Line 21: | ||
* with a built-in interface to compiled code (MEX), Matlab allows to translate computationally intensive operations (recursion, etc.) into compiled code for speedup | * with a built-in interface to compiled code (MEX), Matlab allows to translate computationally intensive operations (recursion, etc.) into compiled code for speedup | ||
* built-in file format to store the content of variables in a binary format (incl. compression and platform independence) | * built-in file format to store the content of variables in a binary format (incl. compression and platform independence) | ||
+ | |||
+ | ==== Built-in functionality ==== | ||
+ | On top of these features, Matlab comes with many, many built-in functions from a variety of fields, among them are | ||
+ | * mathematical functions (sum, mean, median, mode, standard deviation/variance, discrete derivatives, convolution, minimum, maximum, etc.) | ||
+ | * list and set related functions (sort, unique, intersect, setdiff, union, etc.) | ||
+ | * rudimentary statistical functions (histogram, correlation coefficient, detrending, etc.) | ||
+ | * matrix operations (inverse, pseudo-inverse, SVD, decomposition, etc.) | ||
+ | * graphical output functions (line, polygon, shape, surface, and scatter plot, annotations, etc.) | ||
+ | * GUI functions (figures, controls, callback handling, etc.) | ||
+ | |||
+ | These features make it usually relatively efficient to create code with complex functionality with just a few lines of code. | ||
+ | |||
+ | ==== User-provided toolboxes ==== | ||
+ | Mathworks additionally provides a user-defined toolbox area on their webserver, [[http://www.mathworks.com/matlabcentral/fileexchange/|File Exchange]], where users can upload their functions (or sets of functions, called toolboxes) which often allows users to solve even complex problems with a minimal effort, given that someone has already solved it before. | ||
===== GUI elements ===== | ===== GUI elements ===== | ||
Line 31: | Line 46: | ||
Additionally, Matlab comes with a built-in Editor, supporting syntax highlighting and augmenting several of the core features of Matlab, as well as a Profiler, a tool to identify bottlenecks in code, i.e. a help to improve the run-time properties (time and memory consumption) of user-written code. | Additionally, Matlab comes with a built-in Editor, supporting syntax highlighting and augmenting several of the core features of Matlab, as well as a Profiler, a tool to identify bottlenecks in code, i.e. a help to improve the run-time properties (time and memory consumption) of user-written code. | ||
+ | |||
+ | ==== Command line ==== | ||
+ | The command line allows the user to enter commands and inspect returned values (text output intermixed with input). Matlab shows a prompt (**''<nowiki>>></nowiki>''**) during normal operation and an extended prompt for debugging (**''<nowiki>K>></nowiki>''**). The command line offers a few additional functions which are extremely helpful: | ||
+ | * pressing the **''cursor-up''** key allows to cycle through previous commands, and if some text is entered before, only entries matching this text are presented | ||
+ | * the **''tab''**-key does not produce a tab-character (indentation) but instead Matlab attempts to auto-complete a series of letters to a "known expression" (variable, field, function, or file name, depending on context) | ||
+ | * when entering expressions with parenthesis (precedence of operations, function arguments, etc.) or brackets/curly braces, Matlab highlights matching pairs to confirm the completeness of the expression | ||
+ | * if an expression is incomplete (e.g. a **''for''** loop is constructed, but the final **''end''** keyword is missing), Matlab expects additional input on the next line (after pressing return) | ||
+ | * whenever an error is encountered while processing a line of input, Matlab indicates the exact position of the problem with a vertical line below the input (pipe character) | ||
+ | * output in the command window supports hyperlinks (in help texts for instance), which gives the user to immediately select a topic of reference for additional information | ||
+ | * the **''display''** function (which is automatically called when an expression is not terminated with a semicolon) provides auto-formatting for all built-in datatypes (incl. arrays) | ||
+ | * to change the current folder or load a MAT-file, drag-and-drop operations can be performed with either Finder (Mac) or Explorer (Windows), by dragging a folder or MAT-file name into the command prompt window | ||
+ | |||
+ | ==== Command history ==== | ||
+ | The history window is particularly useful when a series of commands is to be converted into an M-file (batch of function file grouping a set of commands/function calls into a new functionality). This can be achieved by selecting several entries (line by line selection) and then using the context menu (right-click or **''CTRL''**-click). To quickly repeat one specific instruction, an entry can also be double-clicked. | ||
+ | |||
+ | ==== Workspace ==== | ||
+ | Equally, the workspace window offers a context menu, which allows to rename variables, delete them from the workspace (same as **''clear VARIABLE''**), save the content of selected variables to disk, or alter their content. | ||
+ | |||
+ | ==== Current folder ==== | ||
+ | The current folder window is a feature-rich file browser, also with additional functionality in the context menu. |