Web (jsp,html) calls to MATLAB programs

Source: Internet
Author: User
Tags tld

This session needs to be prepared JDK and JAVA compilers, and the deployment Project Server, this section uses Eclipse and Tomcat.

1,    engineering, need to introduce Javabuild.jar and Matlab jar

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/85/F2/wKioL1ewYLvDzfZdAACID4KcGWo594.png "title=" 1.png " alt= "Wkiol1ewylvdzfzdaacid4kcgwo594.png" style= "padding:0px;margin:0px;vertical-align:top;border:none;"/>

2, the following for the Matlab function math.jar call, divided into 2 ways, this article only for simple testing, do not set up a Web framework to address.

3,    Test call Sum2.jar

A Create JSP page, in the JSP page header file Reference package

<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%><%@ page import= " com.mathworks.toolbox.javabuilder.* "%><%@ page import=" com.mathworks.toolbox.javabuilder.internal.* "%> <%@ page import= "Math.mathclass"%>

The Middle 2 is introduced as a package and exception handling support that needs to be introduced, and the last object that corresponds to the Matlab function JAR package.

Add code in page <body>

<% object[] result = NULL;    MathClass ms = new MathClass (); result = Ms. Mathtest (1, one, one);%>

Deploy the Web project to Tomcat, where the deployment process is omitted.

then start directly Tomcat, accessing the corresponding path : http://localhost:8080/matlabDraw/index.jsp

If the access is not error, the result is thecorrect output, the test is successful.

B Use this method if you need to call a drawing type.

in the Web project,the Web-inf directory to add the WEBFIGURES.TLD tag Library, the file in Matlab ,matlab\r2012a\ Toolbox\javabuilder\webfigures


Add a tag to the JSP page with the exception of

<%@ taglib prefix= "WF" uri= "/web-inf/webfigures.tld"%<%@ page import= " Com.mathworks.toolbox.javabuilder.webfigures.WebFigure "%>


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/85/F2/wKioL1ewYP7wfXdkAADHqA8GpUE448.png "title=" 2.png " alt= "Wkiol1ewyp7wfxdkaadhqa8gpue448.png" width= "650" style= "Padding:0px;margin:0px;vertical-align:top;border: none; "/>

in Web. XML, Please also add the introduction webfigures,

<servlet> <servlet-name>WebFigures</servlet-name> <servlet-class> Com.mathworks.toolb Ox.javabuilder.webfigures.WebFiguresServlet </servlet-class></servlet><servlet-mapping> < Servlet-name>webfigures</servlet-name> <url-pattern>/webfigures/*</url-pattern></ Servlet-mapping>

Finally, add the following tag to the page to get the function return object Webfigure, and then perform the presentation.

<wf:web-figure name= "Yourfigure" scope= "Session"/>



MATLAB classification has a full set of installation procedures, algorithm writing, program calls, error summary of the solution, you can view the details.

This article from "Around" blog, declined reprint!

Web (jsp,html) calls to MATLAB programs

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.