MATLAB BUILDER JA 2 User's Guide Page 234

  • Download
  • Add to my manuals
  • Print
  • Page
    / 292
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 233
5 Sample Applications (Java)
The program listing is shown here.
createplot.java
/* createplot.java
* This file is used as an example for the MATLAB
* Builder for Java 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++)
{
5-4
Page view 233
1 2 ... 229 230 231 232 233 234 235 236 237 238 239 ... 291 292

Comments to this Manuals

No comments