Schweitzer Fachinformationen
Wenn es um professionelles Wissen geht, ist Schweitzer Fachinformationen wegweisend. Kunden aus Recht und Beratung sowie Unternehmen, öffentliche Verwaltungen und Bibliotheken erhalten komplette Lösungen zum Beschaffen, Verwalten und Nutzen von digitalen und gedruckten Medien.
The word "Matlab" is an acronym for MATrix LABoratory. Matlab is a powerful technical computing environment and a high-level computer programming language, which provides core mathematics and advanced graphical tools for data analysis, visualisation, as well as algorithm and application development. Matlab is intuitive and easy to use, but it requires the use of command-line interface. That is, contrary to other image-analysis software products, which have interfaces and buttons, in Matlab the user needs to type commands to perform tasks. This may seem daunting for experienced users of graphical/text user interfaces. However, with a little practice the command-line becomes easy to use. Furthermore, graphical user interfaces can be created within Matlab. Many common functions, algorithms, matrix manipulation routines and plotting options are available in the main Matlab program or on one of the many toolboxes that accompany Matlab.
There are several ways to start Matlab: through the "Matlab Icon" on the Desktop, which appears on the Desktop of your computer after installation of Matlab, on Macs it should be under "Applications>Matlab" and on Windows in "Start>Programs". The following figure shows the location of the icons in a Mac Operating System.
When you start Matlab, one or more windows will appear once the programme has been launched. These may include the 'Desktop', 'Help Window', and 'm-file Editor', as shown in the following figure. You can later configure which windows to launch with Matlab.
'Desktop'
'Help Window'
'm-file Editor'
The main window is the 'Desktop', which is subdivided into several sections. The 'Command Window' is where the instructions or commands are written to perform a given task. The user will type the instructions in the 'Command Window'. For example, we can add two numbers, 2 and 5, and store the result in the variable 'a' by typing the following in the 'Command Window':
'Command Window'
'a'
a = 2 + 5
a =
7
To execute commands, the user must press the "enter" or "return" key after typing each command. It is possible to have one or more commands in a single line, which is sometimes called a line of instructions. After being executed, each line is stored in the 'Command History' window, together with the date when the command was written. This can be very useful for repeating commands that were typed in the past or for finding the commands that generated a certain result. The Command Window is the first place where commands are used, but if a complex task is needed, it may be better to store the commands in a file called an 'm-file', which can be saved, edited and debugged.
'Command History'
'm-file'
The 'm-files' are files of Matlab code that can be used as 'scripts' or 'functions'. Scripts are files in which a series of commands are written. When the file is 'run', all the commands will be executed in the sequence in which they have been written. Functions are different; when a script is executed, any variable that exists already in Matlab may be used. Functions have no knowledge of anything that exists outside the function. In order for a function to know a certain value (stored in a variable), this variable has to be "passed" to the function as input values or 'arguments'. In the same way, any variables that are created inside a script remain in the 'workspace' after the script is executed. With functions the opposite is true; all intermediate variables created inside a function are deleted once the function finishes its execution unless we specifically 'pass' out the variable as an output argument.
'm-files'
'scripts'
'functions'
'run'
'arguments'
'workspace'
'pass'
To edit the scripts or functions, Matlab provides an 'm-file editor', which is a special text editor that understands Matlab; it highlights the code in different colours so that it is easier to read, it highlights possible errors in the code and suggests improvements and it is very powerful to debug large functions. It even allows the creation of documents. This entire book has been written in the Matlab Editor.
'm-file editor'
When the commands assign values to variables, a list of variables is displayed on the 'workspace'. Some characteristics of the variables such as their dimensions, value, class ('double', 'single', 'char', 'cell', etc.) are shown. To visualise the details of the variable or to modify some of the contents, a double-click on the variable will display it on the 'Array Editor'. The 'Help Window' provides detailed information about Matlab, functions, editors and toolboxes. New windows can be used, for example when graphics are displayed as will be shown in the next section.
('double', 'single', 'char', 'cell'
'Array Editor'
In MATLAB everything is a matrix. A matrix should be understood in the mathematical sense as defined by the Oxford English Dictionary: "A rectangular array of symbols or mathematical expressions arranged in rows and columns, treated as a single entity, and now usually written within round brackets" and not as any of the other definitions such as "the uterus of a mammal" or "the amorphous or fibrillar material that surrounds cells". Table 1 in the preface shows some terms with extremely different meanings within the context of the Life Sciences and that of Mathematics and Engineering. Therefore, a single number can be understood as a matrix of dimensions 1 × 1, i.e. one row and one column. A pair of numbers can be understood as a matrix of dimensions 2 × 1 or 1 × 2. This notion of "matrix orientation" (horizontal or vertical) is a very important concept and will be very relevant once operations are performed. Four numbers can be the elements of matrices with dimensions 4 × 1, 1 × 4 or 2 × 2. It is not possible to leave "empty" spaces inside a matrix. For example it would not be possible to place three of the four elements in the first row and the remaining element in the second row. That matrix would automatically become a 2 × 3 matrix, that is two rows, three columns. The "empty" spaces in the second row would be filled with zeros.
The values of a matrix, that is, the matrix itself, can be assigned to a "variable", which will store the values. The variable can be understood as the name by which the matrix will be known. The basic objective of saving matrices as variables is that they can later be used in conjunction with other variables. For example, to store the value of 5 in a matrix with the name 'a', the following code is typed in the Command Window after the prompt (>>):
a = 5
5
After pressing enter, the value is stored, the workspace will show an entry for 'a' and Matlab will "echo" the answer to the command entered in the Command Window. In this case, the echo just repeats what was typed before, but it can be used to find the solution of an equation with more data. For instance:
"echo"
b = 45 + 123 + a
b =
173
Notice that we used the matrix 'a' as one of the values to be added and stored in the variable 'b'. In this way, Matlab can be used as a simple calculator. If we are not interested in saving the result, there is no need to assign it to a variable. Matlab will store it in a temporary variable called 'ans' (short of answer).
'b'
'ans'
The order of precedence in which the operations are carried out is the following: exponentiation, multiplication/division and then addition and subtraction. This order can be modified by using round brackets. The order is sometimes referred to with the acronyms "BODMAS" or "BIDMAS", which stand for "Brackets, Order of, Division, Multiplication, Addition, Subtraction" and "Brackets, Indices (powers and roots), Division, Multiplication, Addition, Subtraction". Therefore, the following instruction line:
1 + 2 * 3 ^ 4
ans =
163
is equivalent to:
1 + (2 * (3 ^...
Dateiformat: ePUBKopierschutz: Adobe-DRM (Digital Rights Management)
Systemvoraussetzungen:
Das Dateiformat ePUB ist sehr gut für Romane und Sachbücher geeignet – also für „fließenden” Text ohne komplexes Layout. Bei E-Readern oder Smartphones passt sich der Zeilen- und Seitenumbruch automatisch den kleinen Displays an. Mit Adobe-DRM wird hier ein „harter” Kopierschutz verwendet. Wenn die notwendigen Voraussetzungen nicht vorliegen, können Sie das E-Book leider nicht öffnen. Daher müssen Sie bereits vor dem Download Ihre Lese-Hardware vorbereiten.Bitte beachten Sie: Wir empfehlen Ihnen unbedingt nach Installation der Lese-Software diese mit Ihrer persönlichen Adobe-ID zu autorisieren!
Weitere Informationen finden Sie in unserer E-Book Hilfe.