gpt4 book ai didi

java - 从 Mathematica 到 Java 的图像

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:33:32 28 4
gpt4 key购买 nike

我尝试从 Mathematica 中获取图像。我尝试评估一些使用包中的方法生成图形的 Mathematica 代码。如果我将代码粘贴到 Mathematica Notebook,图形将正确生成。

所以我的问题:

如何将此图形转换为 Java???

这是我的示例代码:

ml = MathLinkFactory.createKernelLink("-linkmode launch -linkname 'F:\\APPS\\Wolfram
Research\\Mathematica\\7.0\\mathkernel.exe'");

ml.addPacketListener(new MyPacketListener());
ml.discardAnswer();
PacketListener stdoutPrinter = new PacketPrinter(System.out);
ml.addPacketListener(stdoutPrinter);
// In stringList there is all the INPUT for Mathematica
for (int i = 0; stringList.size() > i; i++)
{
System.out.println("Input" + "[" + i + "]" + stringList.get(i));
ml.evaluate(stringList.get(i));
ml.discardAnswer();
}
ml.close();



class MyPacketListener implements PacketListener {
public boolean packetArrived(PacketArrivedEvent evt)
throws MathLinkException {
if (evt.getPktType() == MathLink.TEXTPKT) {
KernelLink ml = (KernelLink) evt.getSource();
System.out.println(ml.getString());
}
return true;
}

输出是:

<<CIP`ExperimentalData`
<<CIP`MLR`
dataSet = CIP`ExperimentalData`GetQSPRDataSet02[];
CIP`Graphics`ShowDataSetInfo[{"IoPairs", "InputComponents", "OutputComponents"},
dataSet];
Number of IO pairs = 2169


Number of input components = 130

Number of output components = 1

mlrInfo = CIP`MLR`FitMlr[dataSet];
mlrInfoInInputForm = InputForm[mlrInfo];
pointSize = 0.025;
CIP`MLR`ShowMlrSingleRegression[{"ModelVsDataPlot", "CorrelationCoefficient"},
dataSet, mlrInfo, GraphicsOptionPointSize -> pointSize];

(*-Graphics-*)
(*
Out 1 : Correlation coefficient = 0.999373
*)
pointSize = 0.01;
CIP`MLR`ShowMlrSingleRegression[{"AbsoluteSortedResidualsPlot",
"AbsoluteResidualsStatistics", "RMSE"},
dataSet, mlrInfo, GraphicsOptionPointSize -> pointSize];

(*-Graphics-

Definition of 'Residual (absolute)': Data - Model

-1
Out 1 : Residual (absolute): Mean/Median/Maximum Value = 1.4 / 9.84 × 10 /

1
> 1.79 × 10

Root mean squared error (RMSE) = 2.063

*)

我如何获得这些 -Graphics- ?

感谢您的帮助!

最佳答案

J/Link 用户指南有很好的代码示例,用于将图形从 Mathematica 发送到 Java: http://reference.wolfram.com/mathematica/JLink/tutorial/CallingJavaFromMathematica.html#29556

关于java - 从 Mathematica 到 Java 的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6375532/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com