OriginLab Corporation - Data Analysis and Graphing Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis                     
 

6.13 Plot Functions with Parameters Defined in a Worksheet

Summary

Origin can plot functions. It also can plot functions with parameters defined in a worksheet. The function graph can be updated automatically as the parameters in the worksheet change.

Plot Functions with Parameters-6.png

Minimum Origin Version Required: Origin 8.0 SR6

What you will learn

This tutorial will show you how to:

  • Define variables from a worksheet in the Set Values dialog box.
  • Plot a function graph with parameters.
  • Update a graph automatically when parameters are changed.

Steps

Let us use this function as an example: y=p0+p1*x+p2*x^2

  1. Set up a worksheet with three parameters p0, p1, p2 stored in Column A, Column B, Column C as shown below.
    Plot Functions with Parameters-1.png
  2. Click on the Add New Columns button Button Add New Columns.png on the Standard toolbar to add a new column to the worksheet.
    Plot Functions with Parameters-2.png
  3. Highlight Column D and then select Column: Set Column Values. Select Auto from the Recalculate drop-down. Type the script shown below to define the parameters in the Before Formula Scripts edit box. Click the OK button to close the dialog box.
    Plot Functions with Parameters-3.png
    Note that there is a green lock icon Icon Recalculate Auto.png on the top right corner of Column D which indicates that the Recalculate Mode is Auto.
    Plot Functions with Parameters-4.png
  4. Click on the New Function button Button New Function.png on the Standard toolbar(If there is not New Function button, select View: Toolbar to open the Customize dialog, and then go to Button Groups tab, select Standard group, and then drog the New Function button to Standard toolbar. ). The Plot Details dialog opens.
  5. In the Plot Details dialog, set the options as follows and click the OK button to close the dialog box.
    Plot Functions with Parameters-5.png
    Click on the Rescale button Button Rescale.png on the Graph toolbar to adjust the graph's scales.
    Plot Functions with Parameters-6.png
  6. The function graph can be updated automatically when the parameters in the first row of the worksheet change. Change the value in the first row of Column 2 from 2 to 3. Click outside this cell to finish editing.
    Plot Functions with Parameters-7.png
    The function graph updates to reflect this change.
    Plot Functions with Parameters-8.png

Scripts

The script used in the Before Formula Scripts edit box of the Set Values dialog box is:

         p0=col(1)[1];  //Specify Column A for p0.
         p1=col(2)[1];  //Specify Column B for p1.
         p2=col(3)[1];  //Specify Column C for p2.

The function in the F1(x) edit box of the Plot Details dialog box is as follows:

        p0+p1*x+p2*x^2
 

© OriginLab Corporation. All rights reserved.