Object[] result = null; /* Stores the result */
int a=10, b=2;
result=abc.operation(4, a, b );
System.out.println(result[0].toString());
System.out.println(result[1].toString());
System.out.println(result[2].toString());
上文返回数据为字符串时,如果result[0]返回的是一个数组,可以通过如下的方法解决
MWNumericArray a = new MWNumericArray(Double.valueOf(result[0].toString()),MWClassID.DOUBLE);
MWNumericArray temp = (MWNumericArray)result[0];
float [][] weights=(float[][])temp.toFloatArray();
返回图像接收方式
Object[] results = matlabModel.FY(2,dep,step_m,step_x,step_y,step_P, stations);
try {
// unpack the WebFigure
MWJavaObjectRef ref = (MWJavaObjectRef)results[0];
userPlot_zj = (WebFigure)ref.get();
MWJavaObjectRef ref1 = (MWJavaObjectRef)results[1];
userPlot_zz = (WebFigure)ref1.get();
session.setAttribute("zj", userPlot_zj);
session.setAttribute("zz", userPlot_zz);
session.setAttribute("myfigureBinder_zj",
new MWHttpSessionBinder(userPlot_zj));
session.setAttribute("myfigureBinder_zz",
new MWHttpSessionBinder(userPlot_zz));
}
finally {
MWArray.disposeArray(results);
}