Matlab

From CVL Wiki

(Difference between revisions)
Jump to: navigation, search
(How to use Matlab on CVL)
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
 +
 
[[Image:Matlab.jpg|right]]
 
[[Image:Matlab.jpg|right]]
 +
=How to use Matlab on CVL=
 +
'''[[Using the CVL|Log in]]''' to the CVL Workstations.
 +
<br><br>Type the following command
 +
  matlab
 +
 
=General Information about Matlab=
 
=General Information about Matlab=
 
MatLab is a program developed by MathWorks Incorporated. This program provides a high-level language and interactive environment that enables
 
MatLab is a program developed by MathWorks Incorporated. This program provides a high-level language and interactive environment that enables
Line 5: Line 12:
  
 
'''The "Toolboxes" that the Virginia Tech license offers are:'''
 
'''The "Toolboxes" that the Virginia Tech license offers are:'''
* [http://www.mathworks.com/products/simulink/ SIMULINK]
+
*Simulink
* [http://www.mathworks.com/products/communications/ Communications]
+
*Aerospace Blockset
* [http://www.mathworks.com/products/control/ Control System]
+
*Aerospace Toolbox
* [http://www.mathworks.com/products/sysid/ System Identification]
+
*Bioinformatics Toolbox
* [http://www.mathworks.com/products/image/ Image Processing]
+
*Communications System Toolbox
* [http://www.mathworks.com/products/neuralnet/ Neural Network]
+
*Computer Vision System Toolbox
* [http://www.mathworks.com/products/optimization/ Optimization]
+
*Control System Toolbox
* [http://www.mathworks.com/products/rtw/ Real-Time Workshop]
+
*Curve Fitting Toolbox
* [http://www.mathworks.com/products/robust/ Robust Control]
+
*DSP System Toolbox
* [http://www.mathworks.com/products/signal/ Signal Processing]
+
*Data Acquisition Toolbox
* [http://www.mathworks.com/products/symbolic/ Symbolic Math]
+
*Database Toolbox
* [http://www.mathworks.com/products/splines/ Spline]
+
*Embedded Coder
* [http://www.mathworks.com/products/statistics/ Statistics]
+
*Fixed-Point Toolbox
* [http://www.mathworks.com/products/curvefitting/ Curve Fitting]
+
*Fuzzy Logic Toolbox
* [http://www.mathworks.com/products/compiler/ MATLAB® Compiler]
+
*Global Optimization Toolbox
* [http://www.mathworks.com/products/database/ Database]
+
*HDL Coder
* [http://www.mathworks.com/products/distribtb/ Distributed Computing]
+
*Image Acquisition Toolbox
* [http://www.mathworks.com/products/fuzzylogic/ Fuzzy Logic]
+
*Image Processing Toolbox
* [http://www.mathworks.com/products/gads/ Genetic Algorithm & Direct Search]
+
*Instrument Control Toolbox
* [http://www.mathworks.com/products/simpower/ SimPowerSystems]
+
*LMI Control Toolbox (Transitioned) 
* [http://www.mathworks.com/products/simbiology/ SimBiology®]
+
*MATLAB Builder NE
* [http://www.mathworks.com/products/simcontrol/ Simulink® Control Design]
+
*MATLAB Coder
* [http://www.mathworks.com/products/stateflow/ Stateflow®]
+
*MATLAB Compiler
* [http://www.mathworks.com/products/viprocessing/ Video and Image Processing Blockset]
+
*MATLAB® C/C++ Math Library (Transitioned) 
* [http://www.mathworks.com/products/wavelet/ Wavelet]
+
*Mapping Toolbox
 +
*Mu-Analysis and Synthesis Toolbox (Transitioned) 
 +
*Neural Network Toolbox
 +
*Optimization Toolbox
 +
*Parallel Computing Toolbox
 +
*Partial Differential Equation Toolbox
 +
*Robust Control Toolbox
 +
*Signal Processing Toolbox
 +
*SimBiology
 +
*SimElectronics
 +
*SimEvents
 +
*SimMechanics
 +
*SimPowerSystems
 +
*Simscape
 +
*Simulink 3D Animation
 +
*Simulink Coder
 +
*Simulink Control Design
 +
*Simulink Fixed Point
 +
*Spline Toolbox (Transitioned) 
 +
*Spreadsheet Link EX
 +
*Stateflow
 +
*Stateflow Coder (Transitioned) 
 +
*Statistics Toolbox
 +
*Symbolic Math Toolbox
 +
*System Identification Toolbox
 +
*Wavelet Toolbox
 +
*xPC Target
  
  
Line 39: Line 72:
  
 
=Installing Matlab=
 
=Installing Matlab=
<font color=red>'''Disclaimer: The information for associating an account with a license is for Virgina Tech faculty only. Students should use their version of Matlab or use the CVL in order to use Matlab.'''</font>
 
== Creating an Account for Matlab ==
 
[[Image:Create_account_0.jpg|thumb|(fg.1) Click on this image for the visual location of the create account option on the Mathworks homepage.]]
 
[[Image:Create_account_2.jpg|thumb|(fg.2) Click on this image for more information for creating an account]]
 
 
 
Go to [http://www.mathworks.com/ Mathworks home page] (fg.1) and click on create account.
 
 
Once you have reached the create account page fill out the E-mail and Password information using your PID (ex.johnsmith@vt.edu) and password. Also fill out the box entitled County/Software Usage Information and select USA for Country/Region and Academic Use on a University Computer for software use. Finally fill out all of the contact information and submit (fg.2)
 
 
[[Image:Create_account_1.jpg]]
 
 
 
 
 
 
 
 
 
 
==Associating Your Account With a License==
 
[[Image:License_Association_0.jpg|thumb|(fg.3) An account main page]]
 
[[Image:License_Association_2.jpg|thumb|(fg.5) How to get your license number]]
 
 
<br>After you have created your account, if you are faculty, you can associate it with a License. To do this make sure you are logged in at the Mathworks website. Once you are logged in go to your account's main page. (fg.3) On the left hand menu there is an option to "Associate with a License" click on that link.  You will now get the option of entering in a License Number (fg.4). The License number can be found by looking up the version on an already installed copy of Matlab. (fg.5)
 
 
 
[[Image:License_Association_1.jpg]]
 
<br><sub>fg.4 License Association Page</sub>
 
 
 
 
 
 
 
 
 
==Installing Matlab on Windows (2000/XP/Vista)==
 
 
<font color=red>'''Note to Faculty and Staff: Before you install MatLab email your system administrator in order to get the information for your PLP and license.dat file.'''</font>
 
 
===Downloading and Installing via the Internet===
 
 
[[Image:Software Download 0.jpg|thumb|fg.6 How to get to the downloads page]]
 
[[Image:Software Download 1.jpg|thumb|fg.7 The Downloads Page]]
 
[[Image:Software Download 2.jpg|thumb|fg.8 PLP Instructions]]
 
[[Image:Software Installation 0.jpg|thumb|fg.11 License Agreement]]
 
 
====Downloading====
 
Go to your account home page and click on Get Licensed Products and Updates (fg.6) Once you are on the downloads page choose the current version of Matlab (R2007a), Windows as the Platform, and a Typical installation (fg.7). Click Download Now to continue. You will be brought to another page that tells you the installation instructions and that you will need your Personal License Password (PLP) during installation, that you should have from an email (fg.8). Select Open not Save to Disk when the download prompt comes up (fg.9). Once you have the download agent opened select to run it (make sure that you unclick the option to always trust content from this publisher fg.9)
 
 
 
[[Image:Software Download 3.jpg]]
 
[[Image:Software Download 4.jpg]]
 
<br><sub>fg.9 Download and Run Agent Prompt </sub>
 
 
<br>You will now have the option where to download the Matlab installation. Have it download to C:\Matlab and click next to continue. You should now have a window that shows you what packages are going to be downloaded, review these and click download. This download should take 15-30 minutes depending on the speed of your internet connection. Once the download is complete click on the Finish button to start the installer.
 
 
====Installing====
 
'''Step 1'''
 
Select Install and click next.
 
<br>'''Step 2'''
 
The next prompt requires you to enter your name (your Virginia Tech PID or actual name will suffice), Organization (Electrical and Computer Engineering), and your PLP (you should have this in an email). Once this information is filled out click next.
 
<br>'''Step 3'''
 
Here you enter the location of the license.dat file. (to create the license.dat file use the information from the email that contains your PLP) Click Next.
 
<br>'''Step 4'''
 
Now you must accept the license agreement by clicking Yes and then clicking next.
 
<br>'''Step 5'''
 
On the installation type prompt choose custom.
 
<br>'''Step 6'''
 
Select the folder that you would like MatLab to be installed (example. C:\MatLab or C:\Program Files\MatLab).
 
<br>'''Step 7'''
 
Select the products that will be installed (if you are not sure what packages you would like to install just click next)
 
<br>'''Step 8'''
 
Confirm that all you have chosen to install is on the installation confirmation page.
 
<br>'''Step 9'''
 
Associate MatLab with all extensions that it uses.
 
<br>'''Step 10'''
 
MatLab will install on your computer and once completed you should be able to run it normally.
 
 
<br> To get a visual representation of all the steps just explained [http://computing.ece.vt.edu/wiki/MatLab_Windows_Installation_Pictures click here].
 
 
 
===Installing from a CD===
 
 
Installing MatLab from a CD is the same as installing MatLab over the internet with the exception of providing the install CD.
 
 
  
 +
Email support@ece.vt.edu for installation directions.
  
 
==Installing Matlab on Linux/UNIX==
 
==Installing Matlab on Linux/UNIX==
  
This Section is under construction
+
*This Section is under construction.
  
 
==Installing Matlab on MAC OSX==
 
==Installing Matlab on MAC OSX==
  
 
==Using the MPI parallel toolbox==
 
==Using the MPI parallel toolbox==
The CVL lab has installed a toolbox that simplifies parallelizing matlab code.  This is the location of the [http://einar.heiberg.se/mpi/index.html Matlab Parallelization Toolkit].  It utilizes a Master/Slave arrangement to automatically login to multiple machines and have them individually run parts of a matlab script.  The majority of the setup and configuration has been done on all of the CVL machines.  More information on how to operate the toolkit can be obtained by typing
+
The CVL lab has installed a toolbox that simplifies parallelizing matlab code.  This is the location of the [http://einar.heiberg.se/mpi/index.html Matlab Parallelization Toolkit].  It utilizes a Master/Slave arrangement to automatically login to multiple machines and have them individually run parts of a matlab script.  The majority of the setup and configuration has been done on all of the CVL machines, but it is not in your matlab path by default.   
help MPI
+
from the matlab command window.
+
  
The [http://computing.ece.vt.edu/MPI/example.m following] is an example of how to implement the toolbox in matlab code
+
*In order to access the MPI toolbox, you must manually add the directory '/software/MPI' to your path, either with the matlab path GUI, or with the command
 +
addpath /software/MPI
 +
*Once this is done, more information on how to operate the toolkit can be obtained by typing
 +
help MPI from the matlab command window.
 +
 
 +
*The [http://computing.ece.vt.edu/MPI/example2.m following] is an example of how to implement the toolbox in matlab code
  
 
  %This part defines how many nodes to try to use
 
  %This part defines how many nodes to try to use
 
  %connects to available machines, and fires a Matlab slave node
 
  %connects to available machines, and fires a Matlab slave node
  Nparallel = 16;
+
  addpath /software/MPI
  S = pstatus
+
%addpath /software/MPI_VAL32
  if ~exist('INIT')
+
    status = psetup('available', Nparallel);
+
%Read the config file set up for the cluster
    INIT=1;
+
mconfig = pconfig;
 +
  %Use all the machines available
 +
  Nparallel = length(mconfig);
 +
%Run this many MATLAB processes per machine.  This should be set to 1 to
 +
%make resources available for others.
 +
Nperhost = 1;
 +
 +
%Fire up matlab on the slaves.  It may be worth using the load-checking
 +
%version of psetup('available', Nparallel*Nperhost);
 +
for j=1:Nparallel
 +
    psetup(mconfig{j}{1}, Nperhost);
 
  end
 
  end
 +
 
   
 
   
 
  %A example of a data set to chew on
 
  %A example of a data set to chew on
  a = rand(64, 64, 100);
+
  a = rand(64, 64, 32);
 
  res = zeros(size(a));
 
  res = zeros(size(a));
 
   
 
   
Line 163: Line 124:
 
  %Finish the parallel profile stats collection
 
  %Finish the parallel profile stats collection
 
  s = pprofile('report');
 
  s = pprofile('report');
 +
 
   
 
   
 
  %Once the main computation is done, shut-down all the slave Matlab nodes
 
  %Once the main computation is done, shut-down all the slave Matlab nodes
  if INIT
+
  MPI_Finalize;
    MPI_Finalize;
+
end
+
  
 
[http://computing.ece.vt.edu/MPI/exampleloop.m Here's] a functional example of an 'exampleloop.m' matlab function
 
[http://computing.ece.vt.edu/MPI/exampleloop.m Here's] a functional example of an 'exampleloop.m' matlab function
Line 180: Line 140:
  
  
One important point to note is that a portion of the MPI toolbox library must be compiled for the platform it's being run on.  This has already been done for most of the CVL machines being run as 64-bit Linux.  If the toolbox is to be used on a 32-bit Linux installation, the command:
+
One important point to note is that a portion of the MPI toolbox library must be compiled for the platform it's being run on.  This has already been done for most of the CVL machines being run as 64-bit Linux.  If the toolbox is to be used on a 32-bit Linux installation, a the [http://computing.ece.vt.edu/MPI/MPI121_CVL.tar.gz MPI library] will have to be installed into your home directory (or somehwere else you have write permission).  It will also have to be added to your matlab path, and
 
  makeMPI
 
  makeMPI
must be issued from the matlab command prompt, and the appropriate mex, mcc, gcc, and g++ compiler must be installed.
+
must be issued from the matlab command prompt.  The matlab installation must include mex, mcc, gcc, and g++ compiler properly installed.
  
  

Latest revision as of 10:42, 3 December 2015


Matlab.jpg

Contents

[edit] How to use Matlab on CVL

Log in to the CVL Workstations.

Type the following command

  matlab

[edit] General Information about Matlab

MatLab is a program developed by MathWorks Incorporated. This program provides a high-level language and interactive environment that enables you to perform computationally intensive tasks faster than with traditional programming languages such as C, C++, and Fortran.

The "Toolboxes" that the Virginia Tech license offers are:

  • Simulink
  • Aerospace Blockset
  • Aerospace Toolbox
  • Bioinformatics Toolbox
  • Communications System Toolbox
  • Computer Vision System Toolbox
  • Control System Toolbox
  • Curve Fitting Toolbox
  • DSP System Toolbox
  • Data Acquisition Toolbox
  • Database Toolbox
  • Embedded Coder
  • Fixed-Point Toolbox
  • Fuzzy Logic Toolbox
  • Global Optimization Toolbox
  • HDL Coder
  • Image Acquisition Toolbox
  • Image Processing Toolbox
  • Instrument Control Toolbox
  • LMI Control Toolbox (Transitioned) 
  • MATLAB Builder NE
  • MATLAB Coder
  • MATLAB Compiler
  • MATLAB® C/C++ Math Library (Transitioned) 
  • Mapping Toolbox
  • Mu-Analysis and Synthesis Toolbox (Transitioned) 
  • Neural Network Toolbox
  • Optimization Toolbox
  • Parallel Computing Toolbox
  • Partial Differential Equation Toolbox
  • Robust Control Toolbox
  • Signal Processing Toolbox
  • SimBiology
  • SimElectronics
  • SimEvents
  • SimMechanics
  • SimPowerSystems
  • Simscape
  • Simulink 3D Animation
  • Simulink Coder
  • Simulink Control Design
  • Simulink Fixed Point
  • Spline Toolbox (Transitioned) 
  • Spreadsheet Link EX
  • Stateflow
  • Stateflow Coder (Transitioned) 
  • Statistics Toolbox
  • Symbolic Math Toolbox
  • System Identification Toolbox
  • Wavelet Toolbox
  • xPC Target


Toolboxes that have been integrated with other Toolboxes:


The Robust Control Toolbox has merged with the following toolboxes

  • Mu-Analysis and Synthesis
  • LMI Control

[edit] Installing Matlab

Email support@ece.vt.edu for installation directions.

[edit] Installing Matlab on Linux/UNIX

  • This Section is under construction.

[edit] Installing Matlab on MAC OSX

[edit] Using the MPI parallel toolbox

The CVL lab has installed a toolbox that simplifies parallelizing matlab code. This is the location of the Matlab Parallelization Toolkit. It utilizes a Master/Slave arrangement to automatically login to multiple machines and have them individually run parts of a matlab script. The majority of the setup and configuration has been done on all of the CVL machines, but it is not in your matlab path by default.

  • In order to access the MPI toolbox, you must manually add the directory '/software/MPI' to your path, either with the matlab path GUI, or with the command
addpath /software/MPI
  • Once this is done, more information on how to operate the toolkit can be obtained by typing
help MPI from the matlab command window.
  • The following is an example of how to implement the toolbox in matlab code
%This part defines how many nodes to try to use
%connects to available machines, and fires a Matlab slave node
addpath /software/MPI
%addpath /software/MPI_VAL32

%Read the config file set up for the cluster
mconfig = pconfig;
%Use all the machines available
Nparallel = length(mconfig);
%Run this many MATLAB processes per machine.  This should be set to 1 to
%make resources available for others.
Nperhost = 1;

%Fire up matlab on the slaves.  It may be worth using the load-checking
%version of psetup('available', Nparallel*Nperhost);
for j=1:Nparallel
    psetup(mconfig{j}{1}, Nperhost);
end


%A example of a data set to chew on
a = rand(64, 64, 32);
res = zeros(size(a));

%Run a parallel profiler on the code to be run to see how much speedup there was (optional)
pprofile on -detail builtin

%The main parallel loop.
%It executes the function 'exampleloop.m'
pfor(1:size(a, 3), 'res(:, :, %d) = exampleloop(a(:, :, %d));');

%Finish the parallel profile stats collection
s = pprofile('report');


%Once the main computation is done, shut-down all the slave Matlab nodes
MPI_Finalize;

Here's a functional example of an 'exampleloop.m' matlab function

function out = exampleloop(in)

tempout = in
N=10000;
for i=1:N
    tempout = inv(tempout) + rand(size(tempout));
end
out = tempout


One important point to note is that a portion of the MPI toolbox library must be compiled for the platform it's being run on. This has already been done for most of the CVL machines being run as 64-bit Linux. If the toolbox is to be used on a 32-bit Linux installation, a the MPI library will have to be installed into your home directory (or somehwere else you have write permission). It will also have to be added to your matlab path, and

makeMPI

must be issued from the matlab command prompt. The matlab installation must include mex, mcc, gcc, and g++ compiler properly installed.


[edit] Help

For any additional questions, comments, or concerns contact your system administrator or post a ticket on Help Desk.

[edit] Additional Links

Mathworks home page
Matlab Tutorials
Additional information about Matlab
Octave A Free alternative to Matlab

Views
Personal tools
Support