Install math-MATLAB in Linux and use Perl scripts to call the MATLAB test program.

Source: Internet
Author: User

I don't know why I wrote this log. Maybe Matlab is rarely used in Linux in the future, and this Perl and Matlab interfaces will not be used.

After the installation is complete, simply record the process.

For the installation of Matlab, please refer to the teacher's blog: http://blog.sina.com.cn/s/blog_5f0fbdee0100mfkq.html

CPAN download math-MATLAB Installation File http://search.cpan.org /~ Math-Matlab-0.08/Zman/

Install file for Math-Matlab-0.08
Step 2: Install a mod_perl enabled web server (http://perl.apache.org/). Okay, first install mod_perl:

Mod_perl installation:

Download mpd_perl 2.0 http://perl.apache.org/download/index.html

The Installation Method in the install file in the mod_perl-2.0.4 folder is:
% Perl makefile. pl mp_apxs =/usr/local/apache2/bin/apxs
% Make & make test
% Make install

However, apxs cannot be found in my centos 5.4 system. Solution:
[Root @ zhuliting MATLAB] # Yum search apxs
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* Base: mirrors.163.com
* Updates: mirrors.163.com
* Addons: mirrors.163.com
* Extras: mirrors.163.com
========================================================== === Matched: apxs =================================================== =====
Httpd-devel.i386: development tools for the Apache HTTP Server.
[Root @ zhuliting MATLAB] # Yum install httpd-devel
...
...
[Root @ zhuliting MATLAB] # Find/-name apxs
/Usr/sbin/apxs
This is the path of apxs, which will be used below.
[Root @ zhuliting mod_perl-2.0.4] # Perl makefile. pl mp_apxs =/usr/sbin/apxs
[Root @ zhuliting mod_perl-2.0.4] #/usr/sbin/apxs-Q libexecdir
The modelus path is displayed:
/Usr/lib/httpd/modules
Append httpd. conf: [you do not need to append it here. If you modify httpd. conf, the HTTP service cannot be enabled.]
Loadmodule perl_module/usr/lib/httpd/modules/mod_perl.so
Last
[Root @ zhuliting mod_perl-2.0.4] # Make & make install

Here, mod_perl installation is complete, we go back to the installation of the Math_Matlab-0.08 ......
[Root @ zhuliting Math-Matlab-0.08] # Perl makefile. pl mp_apxs =/usr/sbin/apxs
Enter command to execute matlab [/usr/local/bin/Matlab-nodisplay-nojvm]:
You cannot press enter here. I use the find command and find that the MATLAB command is in/usr/local/Matlab/bin/MATLAB. Therefore, I manually enter: /usr/local/Matlab/bin/Matlab-nodisplay-nojvm
After you press enter, the following message is displayed:
Attempting to run MATLAB... which: No shopt in (/usr/lib/qt-3.3/bin:/usr/Kerberos/sbin:/usr/Kerberos/bin:/usr/local/sbin: /usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/x11r6/bin:/root/bin)
OK
Checking if your kit is complete...
Looks good
'Mp _ apxs 'is not a known makemaker parameter name.
Writing makefile for math-MATLAB

Most of the tests for the server and remote classes of
Math: MATLAB package are not run by default.

In order to test them, you will need to set up a server according to
Instructions in the install file, then edit the 'server. config' File
With the appropriate values and re-run 'make test '.

Execute step 2 of the install file for the Math-Matlab-0.08
[Root @ zhuliting Math-Matlab-0.08] # make install
Steps 5 to 3rd are not clear
If you don't quite understand what to do, do nothing. So far, math-MATLAB can be used on a local computer.
I wrote a test program and succeeded ...... That's it.

Attached Perl testing program:
#! /Usr/bin/perl
Use math: MATLAB: local;

$ MATLAB = Math: MATLAB: local-> New ({

Cmd => '/usr/local/Matlab/bin/Matlab-nodisplay-nojvm ',

Root_mwd => '/etc/httpd/Matlab-Server'

});

 
# My $ code = Q/fprintf ('Hello world! /N ');/;
My $ code = Q/disp (pinv ([1 2; 3 4; 5 6;]);/;

If ($ Matlab-> execute ($ Code )){

Print $ Matlab-> fetch_result;

} Else {

Print $ Matlab-> err_msg;

}

 

 

In addition:

# $ Matlab-> execute ($ code, "/etc/httpd/Matlab-server", "zlt. m") can execute M files in the specified directory

For example:

 

#! /Usr/bin/perl

Use math: MATLAB: local;

$ MATLAB = Math: MATLAB: local-> New ({

Cmd => '/usr/local/MATLAB 2009a/bin/Matlab-nodisplay-nojvm ',

Root_mwd => '/etc/httpd/Matlab-Server'

});

 

My $ code = '';

If ($ Matlab-> execute ($ code, "/etc/httpd/Matlab-server", "zlt. m ")){

Print $ Matlab-> fetch_result;

} Else {

Print $ Matlab-> err_msg;

}

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.