MATLAB

From Alliance Doc
Revision as of 14:03, 15 August 2017 by Mboisson (talk | contribs)
Jump to navigation Jump to search


This article is a draft

This is not a complete article: This is a draft, a work in progress that is intended to be published into an article, which may or may not be ready for inclusion in the main wiki. It should not necessarily be considered factual or authoritative.




Using Matlab on Compute Canada systems

There are two main ways of using Matlab on Compute Canada systems. The first one involves bringing your own license, typically owned by your institution, faculty, department or lab. The second one involves compiling your code into a binary, which you can then run using the Matlab Compiler Runtime (MCR) libraries.

Using your own license

Compute Canada is a hosting provide for Matlab. This means that we have Matlab installed on our clusters, but we do not provide a generic license accessible to everyone. However, many institutions, faculty or department already have licenses that can be used on our cluster. In general, any research license can be used on our clusters, and more precisely, any "Total Academic Headcount" license is allowed to be used on our infrastructure. We have received written confirmation from Mathworks that this is allowed by their licenses. This is however not obvious in the wording of the license. If the person managing your license is arguing that it cannot be used outside of your campus, you should encourage them to reach out to their Mathworks representative to confirm with them.

Once the legal aspects are worked out, there will be remaining technical aspects. Namely, the license server on your end will need to be reachable by our compute nodes. This will require our technical team to get in touch with the technical people managing your license software. In some cases, this has already been done. You should then be able to load the matlab module, and it should find its license automatically. If this is not the case, please write to [support@computecanada.ca support@computecanada.ca], so that we can arrange this for you.

Using the Matlab Compiler Runtime libraries

This requires you to have access to the Matlab compiler on a Linux platform. Note that Compute Canada's hosting provider license agreement does not allow us to get the compiler. Please note that the m-file must contain a function statement - script m-files cannot be used directly with the MATLAB compiler. See documentation for the compiler at the Mathworks web site. Here is an example function m-file.


File : cosplot.m

function cosplot()
% MATLAB M-file example to approximate a sawtooth 
% with a truncated Fourier expansion. 
nterms=5; 
fourbypi=4.0/pi; 
np=100; 
y(1:np)=pi/2.0; 
x(1:np)=linspace(-2.0*pi,2*pi,np); 

for k=1:nterms 
 twokm=2*k-1; 
 y=y-fourbypi*cos(twokm*x)/twokm^2; 
end; 

%(The following commands for generating graphics output work 
% with MATLAB 7 on glacier but produce empty plots with MATLAB 6 
% on some other systems.) 
plot(x,y); 
print -dpsc matlab_test_plot.ps; 
quit;
end


To compile it, you would use the command

Question.png
[name@server ~]$ mcc -m cosplot.m

This will produce a binary, as well as a wrapper script.