个人工具

“UbuntuHelp:MATLAB”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
 
(未显示同一用户的3个中间版本)
第2行: 第2行:
 
{{Languages|UbuntuHelp:MATLAB}}
 
{{Languages|UbuntuHelp:MATLAB}}
 
Parent page: [[UbuntuHelp:Programming| Programming Applications]]
 
Parent page: [[UbuntuHelp:Programming| Programming Applications]]
Consider using [[UbuntuHelp:Octave]] instead, which is Free Software.
+
== Introduction ==
The MATLAB site is http://www.mathworks.com/
+
MATLAB® is 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.
=== MATLAB R2006a Installation Instructions ===
+
You can use MATLAB in a wide range of applications, including signal and image processing, communications, control design, test and measurement, financial modeling and analysis, and computational biology. Add-on toolboxes (collections of special-purpose MATLAB functions, available separately) extend the MATLAB environment to solve particular classes of problems in these application areas.
1. Run the MATLAB installer
+
MATLAB provides a number of features for documenting and sharing your work. You can integrate your MATLAB code with other languages and applications, and distribute your MATLAB algorithms and applications.
 +
== MATLAB R2010a Installation Instructions ==
 +
You will need superuser privileges. The assumption is that MATLAB install files are in '''/media/MATHWORKS_R2010A'''.
 +
1. Create the directory MATLAB will be installed to. It is recommended that you use '''/usr/local/matlabR2010a''':
  
Insert CD 1 of 3 and then
 
 
<pre><nowiki>
 
<pre><nowiki>
sudo sh /media/cdrom/install
+
sudo mkdir /usr/local/matlabR2010a
 
</nowiki></pre>
 
</nowiki></pre>
2. Run MATLAB's post installation script
+
2. Change your working directory to the directory MATLAB will be installed to:
  
 
<pre><nowiki>
 
<pre><nowiki>
sudo /usr/local/matlab72/install_matlab
+
cd /usr/local/matlabR2010a/
 
</nowiki></pre>
 
</nowiki></pre>
(discussed in this thread http://ubuntuforums.org/showthread.php?t=19855)
+
3. Run the MATLAB installer:
3. Start MATLAB (if you created simlinks):
+
  
 
<pre><nowiki>
 
<pre><nowiki>
/usr/local/bin/matlab
+
sudo sh /media/MATHWORKS_R2010A/install
 
</nowiki></pre>
 
</nowiki></pre>
You can pass additional options to start MATLAB, in the format '''matlab -option'''.  Here are a few of the most popular ones.
+
If you are running the student version on a 64-bit machine, you need to set the -glnx86 flag:
 
<pre><nowiki>
 
<pre><nowiki>
-nodesktop            Start MATLAB in a console, without the GUI - much faster loading.
+
sudo sh /media/MATHWORKS_R2010A/install_unix.sh -glnx86
-nosplash              Don't show that annoying MATLAB splash screen as it loads.
+
-nojvm                Do not start Java support.  This also causes -nodesktop.
+
-r "command"          Start MATLAB and execute the given command.
+
-h                    Show more MATLAB options.
+
 
</nowiki></pre>
 
</nowiki></pre>
An example command would be '''matlab -nojvm -nosplash -r "1+1"'''
+
/!\ '''DO NOT START MATLAB AT THE END OF THE INSTALLATION'''
=== Installing from an ISO Image ===
+
''Starting MATLAB at the end of Product Activation creates a permissions problem for storing MATLAB preferences, since the directory and files inside of ~/.matlab will be created for the root user. However this inconvenience can be easily fixed running the following command:''
Alternatively to burning the 3 CDs to cd-rom, you can just mount the iso image and install directly from it.
+
Prepare iso mounting:
+
 
<pre><nowiki>
 
<pre><nowiki>
sudo mkdir /media/iso
+
sudo chown -R ${USER}:${USER} ~/.matlab
sudo modprobe loop
+
 
</nowiki></pre>
 
</nowiki></pre>
Then mount the first disk:
+
=== Create A MATLAB Launcher ===
 +
1. Get an icon:
 +
 
 
<pre><nowiki>
 
<pre><nowiki>
sudo mount MathWorks_2006b1m.iso /media/iso/ -t iso9660 -o loop
+
sudo wget http://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png -O /usr/share/icons/matlab.png
 
</nowiki></pre>
 
</nowiki></pre>
And to unmount it:
+
2. Get the launcher file:
 +
 
 
<pre><nowiki>
 
<pre><nowiki>
sudo umount /media/iso/
+
sudo wget 'https://help.ubuntu.com/community/MATLAB?action=AttachFile&do=get&target=matlab-r2010a.desktop' -O /usr/share/applications/matlab.desktop
 
</nowiki></pre>
 
</nowiki></pre>
=== Modes of Operation ===
+
=== MEX functions ===
At a minimum, you don't need much to run MATLAB. It will run in the console without X just fine, though naturally missing some functionality such as graphing. Most users, however, use many of the bells and whistles. The Prerequisites section is made with that in mind.
+
If you try to compile MEX functions you may see a message like the following:
To use the MATLAB desktop, GUIDE, Simulink, and all the nice graphs, you need to have [[UbuntuHelp:Java]] installed, and the executable in your path. If you don't, you'll have to run from a terminal, which isn't always the greatest. A quick way to check to see if you have Java in your path is to open a terminal and type '''which java'''. If it comes back with something similar to '''/usr/local/bin''', you're good to go, otherwise you need to follow the instructions in the [[UbuntuHelp:Java]] How-To.
+
<pre><nowiki>
You will get far better performance making complex graphs if hardware accelerated openGL rendering is set up properly.  Open up a terminal and run the following command.
+
 
 +
Warning: You are using gcc version "4.4.3-4ubuntu5)".  The version
 +
        currently supported with MEX is "4.2.3".
 +
        For a list of currently supported compilers see:  
 +
        http://www.mathworks.com/support/compilers/current_release/
 +
 
 +
</nowiki></pre>
 +
'''Note''' this is a warning - the MEX function will still compile.
 +
The following instructions will setup gcc 4.2 and make it the default compiler for MATLAB on versions of Ubuntu prior to 10.04 LTS (Lucid):
 +
1. Install The GNU Compiler Collection 4.2 and The GNU Standard C++ Library
 +
 
 +
<pre><nowiki>
 +
sudo aptitude install gcc-4.2-multilib libstdc++6-4.2-dev
 +
</nowiki></pre>
 +
2. Make a MATLAB specific 'bin' directory for gcc symlink.
 +
 
 +
<pre><nowiki>
 +
mkdir ~/.matlab/bin
 +
</nowiki></pre>
 +
3. Symlink gcc to gcc-4.2 via user MATLAB specific 'bin' directory.
 +
 
 +
<pre><nowiki>
 +
ln -s /usr/bin/gcc-4.2 ~/.matlab/bin/gcc
 +
</nowiki></pre>
 +
4. Add MATLAB specific 'bin' directory to the front of your system $PATH within your local startup.m file.
 +
 
 
<pre><nowiki>
 
<pre><nowiki>
glxinfo | grep direct
+
printf "setenv(\'PATH\',sprintf(\'/home/%%s/.matlab/bin:%%s\',getenv(\'USER\'),getenv(\'PATH\'));\n" >> ~/Documents/MATLAB/startup.m
 
</nowiki></pre>
 
</nowiki></pre>
If the output is `direct rendering: Yes`, then you should be fine.  Otherwise you might be able to get it working using non-free graphics drivers.  See [[UbuntuHelp:BinaryDriverHowto|BinaryDriverHowto]].  If this doesn't solve your problem, you might have trouble getting direct rendering working on your card.  If you are still interested, you might want to search for information on your specific card model and see if anyone else has gotten direct rendering working.
+
=== Possible Problems ===
=== Missing cellfun.mexglx (and other files) ===
+
==== Preferences Permission ====
If you are installing Matlab (Version 7.0.1.24704 (R14) Service Pack 1) on a x86 machine with Ubuntu (Breezy Badger)  there could be some problems with the permissions on file '''/etc/libc.so.6''', which, by default, does not have executable permission and does not behave like it is expected by some scripts. When some scripts (install and startup scripts) try to query the version of the libc file, they are returned empty strings. Possibly because of this issue, some of the mexglx files are not installed and when matlab starts up, the script '''${matlab_dir}/bin/util/oscheck.sh''' also reports the following error.
+
When you launch your MATLAB Desktop you might see an error message similar to the following:
 
<pre><nowiki>
 
<pre><nowiki>
/opt/matlab/bin/util/oscheck.sh: line 134: /lib/libc.so.6: Permission denied
+
The desktop configuration was not saved successfully
 +
Cannot write to preference file "matlab.prf" in "/home/username/.matlab/R2010a".
 +
Check file permissions.
 
</nowiki></pre>
 
</nowiki></pre>
The file '''${matlab_dir}/toolbox/matlab/datatypes/cellfun.mexglx''' was not installed and this could cause problems when trying to execute a simple command such as '''ls''', for e.g.,
+
You can resolve this by exiting all instances of MATLAB and issuing the following command in your terminal:
 
<pre><nowiki>
 
<pre><nowiki>
>> ls
+
sudo chown -R ${USER}:${USER} ~/.matlab
??? Attempt to execute SCRIPT cellfun as a function.
+
Error in ==> iscellstr at 13
+
  res = cellfun('isclass',s,'char');
+
Error in ==> ls at 16
+
if iscellstr(varargin)
+
 
</nowiki></pre>
 
</nowiki></pre>
One way to solve this would be to modify two lines in the scripts '''${matlab_dir}/bin/util/oscheck.sh''' as well as in the script '''${matlab_install_cd}/install'''. Line 697 of '''${matlab_install_cd}/install'''
+
==== Missing JRE ====
 +
If you are using the student version on a 64-bit system, generate and paste the license.dat file in the /matlab/licenses folder. You may need to contact MATLAB support to generate the dat file.
 +
== Previous Versions ==
 +
Instructions for previous versions can be found here.
 +
* [[UbuntuHelp:MATLAB/R2009b|R2009b]]
 +
== External Links ==
 +
For more information about MATLAB see the following links
 +
* < http://www.mathworks.com/ > - MathWorks - MATLAB and Simulink for Technical Computing.
 +
* < http://www.mathworks.com/products/matlab/ > - MATLAB - The Language Of Technical Computing
 +
* < http://www.mathworks.com/access/helpdesk/help/techdoc/matlab.html > - MATLAB Documentation.
 +
* < http://www.mathworks.com/support/ > - The MathWorks Support.
 +
* < http://www.mathworks.com/matlabcentral/ > - MATLAB Central.
 +
* < http://www.mathworks.com/matlabcentral/fileexchange/ > - MATLAB Central File Exchange.
 
----
 
----
 
[[category:CategoryScience]]
 
[[category:CategoryScience]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2010年5月19日 (三) 23:23的最新版本


Parent page: Programming Applications

Introduction

MATLAB® is 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. You can use MATLAB in a wide range of applications, including signal and image processing, communications, control design, test and measurement, financial modeling and analysis, and computational biology. Add-on toolboxes (collections of special-purpose MATLAB functions, available separately) extend the MATLAB environment to solve particular classes of problems in these application areas. MATLAB provides a number of features for documenting and sharing your work. You can integrate your MATLAB code with other languages and applications, and distribute your MATLAB algorithms and applications.

MATLAB R2010a Installation Instructions

You will need superuser privileges. The assumption is that MATLAB install files are in /media/MATHWORKS_R2010A. 1. Create the directory MATLAB will be installed to. It is recommended that you use /usr/local/matlabR2010a:

sudo mkdir /usr/local/matlabR2010a

2. Change your working directory to the directory MATLAB will be installed to:

cd /usr/local/matlabR2010a/

3. Run the MATLAB installer:

sudo sh /media/MATHWORKS_R2010A/install 

If you are running the student version on a 64-bit machine, you need to set the -glnx86 flag:

sudo sh /media/MATHWORKS_R2010A/install_unix.sh -glnx86

/!\ DO NOT START MATLAB AT THE END OF THE INSTALLATION Starting MATLAB at the end of Product Activation creates a permissions problem for storing MATLAB preferences, since the directory and files inside of ~/.matlab will be created for the root user. However this inconvenience can be easily fixed running the following command:

sudo chown -R ${USER}:${USER} ~/.matlab

Create A MATLAB Launcher

1. Get an icon:

sudo wget http://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png -O /usr/share/icons/matlab.png

2. Get the launcher file:

sudo wget 'https://help.ubuntu.com/community/MATLAB?action=AttachFile&do=get&target=matlab-r2010a.desktop' -O /usr/share/applications/matlab.desktop

MEX functions

If you try to compile MEX functions you may see a message like the following:


Warning: You are using gcc version "4.4.3-4ubuntu5)".  The version
         currently supported with MEX is "4.2.3".
         For a list of currently supported compilers see: 
         http://www.mathworks.com/support/compilers/current_release/

Note this is a warning - the MEX function will still compile. The following instructions will setup gcc 4.2 and make it the default compiler for MATLAB on versions of Ubuntu prior to 10.04 LTS (Lucid): 1. Install The GNU Compiler Collection 4.2 and The GNU Standard C++ Library

sudo aptitude install gcc-4.2-multilib libstdc++6-4.2-dev

2. Make a MATLAB specific 'bin' directory for gcc symlink.

mkdir ~/.matlab/bin

3. Symlink gcc to gcc-4.2 via user MATLAB specific 'bin' directory.

ln -s /usr/bin/gcc-4.2 ~/.matlab/bin/gcc

4. Add MATLAB specific 'bin' directory to the front of your system $PATH within your local startup.m file.

printf "setenv(\'PATH\',sprintf(\'/home/%%s/.matlab/bin:%%s\',getenv(\'USER\'),getenv(\'PATH\'));\n" >> ~/Documents/MATLAB/startup.m

Possible Problems

Preferences Permission

When you launch your MATLAB Desktop you might see an error message similar to the following:

The desktop configuration was not saved successfully
Cannot write to preference file "matlab.prf" in "/home/username/.matlab/R2010a".
Check file permissions.

You can resolve this by exiting all instances of MATLAB and issuing the following command in your terminal:

sudo chown -R ${USER}:${USER} ~/.matlab

Missing JRE

If you are using the student version on a 64-bit system, generate and paste the license.dat file in the /matlab/licenses folder. You may need to contact MATLAB support to generate the dat file.

Previous Versions

Instructions for previous versions can be found here.

External Links

For more information about MATLAB see the following links