1740
Comment:

7179

Deletions are marked like this.  Additions are marked like this. 
Line 3:  Line 3: 
= Basics =  = Matlab = Matlab is a highlevel language and interactive environment for numerical computation, visualization, and programming. 
Line 5:  Line 6: 
* Matlab is a highlevel language and interactive environment for numerical computation, visualization, and programming. * Start it on Linux: Applications  Accessories  Terminal. Then type: Matlab (Enter) 
== Start Matlab == * Start it on Linux: Applications  Accessories  Terminal. Then type: matlab (Enter) 
Line 9:  Line 10: 
= Deutsch = == Limitierte Anzahl Lizenzen == Die Anzahl der MATLABLizenzen ist begrenzt. Um einen fairen und effizienten Gebrauch dieser Lizenzen in der gesamten ETH zu gewährleisten wurden folgende Maßnahmen getroffen: * Lizenzen werden zurückgegeben, wenn keine Nutzung seit 4 Stunden erfolgte * Die übermäßige Verwendung von Lizenzen wird überwacht und Benutzer werden aufgefordert wenn nötig Lizenzen zurückzugeben 
== First Steps == Matlab has a lot of tutorials by its own. You can find them in Matlab: Help  Product Help  User Guides 
Line 15:  Line 13: 
== Was können Sie tun? == 1) Beenden Sie MATLAB wenn Sie fertig sind. Nur dann werden alle verwendeten Lizenzen zurückgegeben. 1) Kompilieren Sie Ihr MATLABProgramm 
= Matlab Compiler = * mcc (both: UNIX and Windows) is the MATLAB Compiler. You can use the mcc command either from the MATLAB command prompt or the commandline * The advantage of a compiled matlab program is, that no matlab license is taken from the ETHlicenses. This means that you should prefer to compile matlab programs for which you intend to run many instances (e.g. hundreds, in a distributed computing setup for instance). If you do not compile the programs, one license is checked out on the ETH server for each Matlab instance you are running. As the overall amount of licenses on the ETH server is limited, checking out hundreds of licenses for a distributed computing job could lead to a license shortage, meaning that you yourself and other users at ETH cannot start new matlab instances, until some allocated licenses have been freed. 
Line 19:  Line 17: 
Der beste Ansatz, eine übermäßige Verwendung von MATLABLizenzen zu vermeiden, ist die Kompilierung Ihres MATLABProgramm. Die resultierende ausführbare Datei braucht keine einzige MATLABLizenz! Dies befreit Sie von allen MATLAB Lizenzbeschränkungen und erlaubt Ihnen ausserdem Ihre ausführbare Datei an Nutzer ohne MATLAB Installation weiterzugeben. 
== How to use Matlab Compiler on Linux == This section shows an example on how to use MATLAB Compiler to code and build standalone applications. 
Line 25:  Line 20: 
c) Registrieren Sie Zeiten in denen viele MATLABLizenzen aufgrund eines MATLABKurses benötigt werden  == Magic Square Example == A magic square is an array of integers arranged so that their sum is the same when added vertically, horizontally, or diagonally. Copy the following code in a textfile and save it as magicsquare.m 
Line 27:  Line 23: 
Mit dieser Registrierung im Voraus können wir Gegenmaßnahmen ergreifen und sicherstellen dass diese Lizenzen zur Verfügung stehen. 
{{{ 
Line 30:  Line 25: 
d) Kaufen Sie Ihre eigenen MATLAB Lizenzen falls Sie einen garantierten 24/7 Service benötigt oder falls Sie eine übermäßige Anzahl an Lizenzen verwenden müssen. 
function m = magicsquare(n) %MAGICSQUARE generates a magic square matrix of the size % specified by the input parameter n. % Copyright 20032011 The MathWorks, Inc. if ischar(n) n=str2num(n); end m = magic(n); m }}} Important: When this programm is executed in a LinuxTerminal, we have to use the function str2num (string to number). Arguments are used as strings, thats why they have to be converted in a number in Matlab. Compile the magicsqure function (with the command: mcc) in a LinuxTerminal * Start a Terminal (Applications  Accessoires  Terminal) and change to the directory where you stored magicsquare.m {{{ mcc mv magicsquare.m }}} * This generates you 2 files: magicsquare and run_magicsquare.sh * magicsquare is the main file of the application. * run_magicsquare.sh is the script to start the application. It sets up the MCR (MATLAB Compiler Runtime) environment for the current $ARCH and executes the specified command. To run the magicsquare programm we give the shellscript 2 arguments. The first is the path to the Matlab Compiler Runtime. '''Important:''' The version of the compiler Runtime needs to be same that was used by the compiler mcc. The second argument in this example is for the programm magicsquare itself. {{{ > ./run_magicsquare.sh /usr/pack/matlab8.1r2013asd 5  Setting up environment variables  LD_LIBRARY_PATH is .:/usr/pack/matlab8.1r2013asd/runtime/glnxa64:/usr/pack/matlab8.1r2013asd/bin/glnxa64:/usr/pack/matlab8.1r2013asd/sys/os/glnxa64:/usr/pack/matlab8.1r2013asd/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/pack/matlab8.1r2013asd/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/pack/matlab8.1r2013asd/sys/java/jre/glnxa64/jre/lib/amd64/client:/usr/pack/matlab8.1r2013asd/sys/java/jre/glnxa64/jre/lib/amd64 m = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 
Line 34:  Line 72: 
== English ==  }}} More help on mcc: Enter on commandline: mcc help Or see the MatlabDocumentation in Matlab: Help  Product Help  Matlab Compiler = Matlab on the cluster (Condor, Grid Engine) = * Every MatlabJob on the cluster uses one license. Therefore its very important, to run only compiled MatlabApplications on the cluster. * Don't expand the Matlab Search Path with a large number of directories on NFSmounted ressources such as your home directory. Don't use the matlab function genpath to expand the Matlab Search Path. * Set the variable MCR_CACHE_ROOT to a directory on your local computer. With MCR_ROOT_CACHE in your homedirectory the NFSLoad on the Homeservers gets too big. {{{ mkdir p /tmp/$USER export MCR_CACHE_ROOT=/tmp/$USER }}} If you get the error message: "Could not access MCRcomponent cache", you have to make it unique (make sure no other user is using the same path) and check the accessibility of this path. * Use the following Options of mcc when compiling: {{{ mcc m R singleCompThread R nodisplay R nojvm foo.m }}} * R singleCompThread: Limits MATLAB to a single computational thread. By default, MATLAB makes use of the multithreading capabilities of the computer on which it is running. * R nodisplay: Do not display any XWindows or Xcommands * R nojvm: Start MATLAB without the JVM software. Any tools that require Java software, such as the desktop tools, cannot be used. Handle Graphics and related functionality are not supported; MATLAB produces a warning when you use them. If you need to use Java software, you can run mcc without this option. = Limited amount of licenses = The number of MATLAB licences is limited. To ensure a fair and efficient usage of the licences throughout the ETH the following measures have been put in place: * licences will be returned if not used for 4 hours * excessive usage of licences will be monitored and users will be asked to return licences if needed == What can you do? == 1. Compile your MATLAB program. The best approach to avoid excessive usage of MATLAB licences is to compile your MATLAB program. The resulting executable does not need ANY MATLAB licence! This frees you from all MATLAB licence restrictions and also allows you to provide your executable to users without a MATLAB installation. 1. Exit MATLAB when finished. Only then will all used licences be given back. 1. Register the need for many MATLAB licences due to a MATLAB course by registering your need in advance, there can be taken countermeasures and ensure that these licences are available. Use the ides contact forumular therefore: https://idts.ethz.ch/hdweb/ (Nethzlogin required) 1. Buy your own MATLAB licences if you must have a guaranteed 24/7 service or if you need to use an excessive amount of licences. == How do I know which MATLAB licences I use? == * The MATLAB command "license('inuse')" lists the licences checked out for the current MATLAB session. == How do I know how many MATLAB licences are used by whom? == * You can list all checkedout MATLAB base licences with the following command on Linux: {{{ lmutil lmstat c 1965@licmatlab.ethz.ch f MATLAB  less }}} * MATLAB base licences and all Toolbox licenses are listed with the following command: {{{ lmutil lmstat c 1965@licmatlab.ethz.ch a  less }}}  [[CategoryBTCH]] 
Contents
Matlab
Matlab is a highlevel language and interactive environment for numerical computation, visualization, and programming.
Start Matlab
 Start it on Linux: Applications  Accessories  Terminal. Then type: matlab (Enter)
 Start it on Windows: Start  Matlab  Matlab
First Steps
Matlab has a lot of tutorials by its own. You can find them in Matlab: Help  Product Help  User Guides
Matlab Compiler
 mcc (both: UNIX and Windows) is the MATLAB Compiler. You can use the mcc command either from the MATLAB command prompt or the commandline
 The advantage of a compiled matlab program is, that no matlab license is taken from the ETHlicenses. This means that you should prefer to compile matlab programs for which you intend to run many instances (e.g. hundreds, in a distributed computing setup for instance). If you do not compile the programs, one license is checked out on the ETH server for each Matlab instance you are running. As the overall amount of licenses on the ETH server is limited, checking out hundreds of licenses for a distributed computing job could lead to a license shortage, meaning that you yourself and other users at ETH cannot start new matlab instances, until some allocated licenses have been freed.
How to use Matlab Compiler on Linux
This section shows an example on how to use MATLAB Compiler to code and build standalone applications.
Magic Square Example
A magic square is an array of integers arranged so that their sum is the same when added vertically, horizontally, or diagonally. Copy the following code in a textfile and save it as magicsquare.m
function m = magicsquare(n) %MAGICSQUARE generates a magic square matrix of the size % specified by the input parameter n. % Copyright 20032011 The MathWorks, Inc. if ischar(n) n=str2num(n); end m = magic(n); m
Important: When this programm is executed in a LinuxTerminal, we have to use the function str2num (string to number). Arguments are used as strings, thats why they have to be converted in a number in Matlab.
Compile the magicsqure function (with the command: mcc) in a LinuxTerminal
 Start a Terminal (Applications  Accessoires  Terminal) and change to the directory where you stored magicsquare.m
mcc mv magicsquare.m
 This generates you 2 files: magicsquare and run_magicsquare.sh
 magicsquare is the main file of the application.
 run_magicsquare.sh is the script to start the application. It sets up the MCR (MATLAB Compiler Runtime) environment for the current $ARCH and executes the specified command.
To run the magicsquare programm we give the shellscript 2 arguments. The first is the path to the Matlab Compiler Runtime.
Important: The version of the compiler Runtime needs to be same that was used by the compiler mcc.
The second argument in this example is for the programm magicsquare itself.
> ./run_magicsquare.sh /usr/pack/matlab8.1r2013asd 5  Setting up environment variables  LD_LIBRARY_PATH is .:/usr/pack/matlab8.1r2013asd/runtime/glnxa64:/usr/pack/matlab8.1r2013asd/bin/glnxa64:/usr/pack/matlab8.1r2013asd/sys/os/glnxa64:/usr/pack/matlab8.1r2013asd/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/pack/matlab8.1r2013asd/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/pack/matlab8.1r2013asd/sys/java/jre/glnxa64/jre/lib/amd64/client:/usr/pack/matlab8.1r2013asd/sys/java/jre/glnxa64/jre/lib/amd64 m = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
More help on mcc: Enter on commandline: mcc help
Or see the MatlabDocumentation in Matlab: Help  Product Help  Matlab Compiler
Matlab on the cluster (Condor, Grid Engine)
 Every MatlabJob on the cluster uses one license. Therefore its very important, to run only compiled MatlabApplications on the cluster.
 Don't expand the Matlab Search Path with a large number of directories on NFSmounted ressources such as your home directory. Don't use the matlab function genpath to expand the Matlab Search Path.
 Set the variable MCR_CACHE_ROOT to a directory on your local computer. With MCR_ROOT_CACHE in your homedirectory the NFSLoad on the Homeservers gets too big.
mkdir p /tmp/$USER export MCR_CACHE_ROOT=/tmp/$USER
If you get the error message: "Could not access MCRcomponent cache", you have to make it unique (make sure no other user is using the same path) and check the accessibility of this path.
 Use the following Options of mcc when compiling:
mcc m R singleCompThread R nodisplay R nojvm foo.m
 R singleCompThread: Limits MATLAB to a single computational thread. By default, MATLAB makes use of the multithreading capabilities of the computer on which it is running.
 R nodisplay: Do not display any XWindows or Xcommands
 R nojvm: Start MATLAB without the JVM software. Any tools that require Java software, such as the desktop tools, cannot be used. Handle Graphics and related functionality are not supported; MATLAB produces a warning when you use them. If you need to use Java software, you can run mcc without this option.
Limited amount of licenses
The number of MATLAB licences is limited. To ensure a fair and efficient usage of the licences throughout the ETH the following measures have been put in place:
 licences will be returned if not used for 4 hours
 excessive usage of licences will be monitored and users will be asked to return licences if needed
What can you do?
 Compile your MATLAB program. The best approach to avoid excessive usage of MATLAB licences is to compile your MATLAB program. The resulting executable does not need ANY MATLAB licence! This frees you from all MATLAB licence restrictions and also allows you to provide your executable to users without a MATLAB installation.
 Exit MATLAB when finished. Only then will all used licences be given back.
Register the need for many MATLAB licences due to a MATLAB course by registering your need in advance, there can be taken countermeasures and ensure that these licences are available. Use the ides contact forumular therefore: https://idts.ethz.ch/hdweb/ (Nethzlogin required)
 Buy your own MATLAB licences if you must have a guaranteed 24/7 service or if you need to use an excessive amount of licences.
How do I know which MATLAB licences I use?
 The MATLAB command "license('inuse')" lists the licences checked out for the current MATLAB session.
How do I know how many MATLAB licences are used by whom?
 You can list all checkedout MATLAB base licences with the following command on Linux:
lmutil lmstat c 1965@licmatlab.ethz.ch f MATLAB  less
 MATLAB base licences and all Toolbox licenses are listed with the following command:
lmutil lmstat c 1965@licmatlab.ethz.ch a  less