Table Of Contents

Creating a Graphical Display of MathScript Results

    Last Modified: December 23, 2016

    Use the MathScript plot functions to create a graphical 2D or logarithmic display of your MathScript results. You can only execute plot functions in the command section of the MathScript Console.

    The following procedure demonstrates how to create a plot in the MathScript Console using a specific example. The example plots the sine and the cosine of the given values. The steps you need to take to complete your specific task might be different than the following steps.

    1. Select View»More»Tools Launcher to open the Tools Launcher.
    2. Click MathScript Console to open the MathScript Console.
    3. Enter the following code in the command section of the MathScript Console to plot the sine and the cosine of the given values. Press Enter after every command.
      x = [0:0.1:2*pi];
      xlabel('x axis');
      ylabel('y axis');
      legend('sin(x)', 'cos(x)');

      The code creates the following plot.

      The commands you entered complete the following actions:
      • x = [0:0.1:2*pi]; creates an array with values from 0 to 2*pi in steps of 0.1. Prevent displaying the output of the values in the command window by finishing the command with a semicolon.
      • clfig clears the current plot window. If no plot window exists, clfig creates a new plot window.
      • xlimit and ylimit set the ranges of the x- and the y-scale.
      • xlabel and ylabel label the axes.
      • plot plots the curve.
      • hold determines that the new cos(x) plot doesn't overwrite the existing sin(x) plot.
      • legend creates a legend of the two plotted curves.

    Recently Viewed Topics