MATLAB的最新版本
新的 Java Builder為我們在Java程序中調用Matlab豐富的數值計算資源提供了極大的便利
與MATLAB對其他程序的外部接口相比
(
(
?SoftID=
鍵入set PATH=%PATH%;C:\Program Files\Java\jdk
鍵入 java
應該有
java version
Java(TM)
(build version_number
Java HotSpot(TM) Client VM (build version_number
鍵入javac
返回 javac version_number
如果以上都沒有問題
新建工程 magicsquare
function y = makesqr(x)
%MAKESQR Magic square of size x
% Y = MAKESQR(X) returns a magic square of size x
% This file is used as an example for the MATLAB
% Builder for Java Language product
% Copyright
y = magic(x);
注意把這個工程和matlb文件都放在放在matalb的workplace文件夾下
/* getmagic
* This file is used as an example for the MATLAB
* Builder for Java Language product
*
* Copyright
*/
/* Necessary package imports */
import com
import magicsquare
/*
* getmagic class computes a magic square of order N
* positive integer N is passed on the command line
*/
class getmagic
{
public static void main(String[] args)
{
MWNumericArray n = null; /* Stores input value */
Object[] result = null; /* Stores the result */
magic theMagic = null; /* Stores magic class instance */
try
{
/* If no input
if (args
{
System
integer
return;
}
/* Convert and print input value*/
n = new MWNumericArray(Double
MWClassID
System
/* Create new magic object */
theMagic = new magic();
/* Compute magic square and print result */
result = theMagic
System
}
catch (Exception e)
{
System
}
finally
{
/* Free native resources */
MWArray
MWArray
if (theMagic != null)
theMagic
}
}
}
運行以上代碼
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26451.html