Tags:
tag this topic
create new tag
view all tags
---+ Using Matlab This page is part of the EmpiricalAlgorithmics web. ---++ Compiling Matlab * Code modification: * the 'main' function is an m-file (myFunction.m) that needs to be a function. * since all arguments are passed as strings, you need to convert numeric arguments to double when 'deployed': =if isdeployed= =myArg1 !== str2double(myArg1); =end= * no 'addpath' calls allowed * for functions called by 'feval', you need to get them included by adding the following to myFunction.m: =%#function myAnnonymousFunction= * Compilation: To compile a function for stand-alone execution, start Matlab in the appropriate directory and type: =addpath(genpath(pwd)); % Add stuff to the path so compiler can find functions= =mcc -m myFunction.m % Compile into a stand-alone= (you can call mcc from outside matlab, but it needs to be called from within matlab to add anything to the path) * Execution: * Set the library environment variable so that it can find the matlab libraries: =setenv LD_LIBRARY_PATH /cs/local/generic/lib/pkg/matlab-7.3/bin/glnx86= (or wherever matlab is installed, this can be added to .cshrc) * Run the stand-alone: =myFunction= ---++ Submitting Compiled Matlab to the Arrow Cluster The configuration that has worked was compiling on arrow50@cs with Matlab 7.3 compiler/libraries. Here is a compile.sh file (run from the 'root' code directory, where $1 is the function you want to compile): =#!/bin/sh= =/cs/local/generic/lib/pkg/matlab-7.3/bin/matlab -nojvm -nosplash -nodesktop -nodisplay -r "addpath(genpath(pwd));mcc -m $1;exit;"= Also, the arrow cluster uses bash instead of cshell, so the library command needs to be: =export LD_LIBRARY_PATH=/cs/local/generic/lib/pkg/matlab-7.3/bin/glnx86= It appears that the right way to get environment variables set is to set them on the qsub command line. So on samos, set your LD_LIBRARY_PATH to be what you want (adding in the matlab directory) and then use the command =qsub -v LD_LIBRARY_PATH=$LD_LIBRARY_PATH -o . -e . -cwd -t 4 ./script= to submit the job. $SGE_TASK_ID causes a complaint from Matlab, so you may need to send explicit integers instead. -- Main.jtillett - 19 Apr 2007 ---++ Common Errors *Problem:* You compiled initially without a problem. You try recompiling and you get this: =??? Error: File: somefile Line: 1 Column: 25= =The input character is not valid in MATLAB statements or expressions.= *Solution:* Delete the mcr directory. *Problem:* You're trying to load a file that has an array of user objects, and when you run it you get an error message like: =Warning: Class ':all:' is an unknown object class. Element(s) of this class in array '' have been converted to structures.= *Solution:* Use the line "%#function my_object" in your code *Problem:* You're trying to compile a MATLAB code, and you get error like: =connect xxx.cs.ubc.ca port 6000: Connection refused.= *Solution:* run "setenv DISPLAY fake_display" before run MATLAB
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r5
<
r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r5 - 2009-03-06
-
xulin730
Home
Site map
BETA web
Communications web
Faculty web
Imager web
LCI web
Main web
SPL web
Sandbox web
TWiki web
TestCases web
BETA Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback