createplot.java
来自「matlab实用教程」· Java 代码 · 共 63 行
JAVA
63 行
/* createplot.java * This file is used as an example for the MATLAB * Builder for Java Language product. * * Copyright 2001-2006 The MathWorks, Inc. *//* Necessary package imports */import com.mathworks.toolbox.javabuilder.*;import plotdemo.*;/* * createplot class demonstrates plotting x-y data into * a MATLAB figure window by graphing a simple parabola. */class createplot{ public static void main(String[] args) { MWNumericArray x = null; /* Array of x values */ MWNumericArray y = null; /* Array of y values */ plotter thePlot = null; /* Plotter class instance */ int n = 20; /* Number of points to plot */ try { /* Allocate arrays for x and y values */ int[] dims = {1, n}; x = MWNumericArray.newInstance(dims, MWClassID.DOUBLE, MWComplexity.REAL); y = MWNumericArray.newInstance(dims, MWClassID.DOUBLE, MWComplexity.REAL); /* Set values so that y = x^2 */ for (int i = 1; i <= n; i++) { x.set(i, i); y.set(i, i*i); } /* Create new plotter object */ thePlot = new plotter(); /* Plot data */ thePlot.drawplot(x, y); } catch (Exception e) { System.out.println("Exception: " + e.toString()); } finally { /* Free native resources */ MWArray.disposeArray(x); MWArray.disposeArray(y); if (thePlot != null) thePlot.dispose(); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?