1.151 FAQ-779 How to create a 2D nested function plot?

Last Update: 8/25/2015


In Origin, we can plot 2D nested functions as below by using matrix objects.


f(\mathbf{x},\mathbf{y})=\sigma(u(\mathbf{x},\mathbf{y}),\mathbf{x},\mathbf{y})

Example

In this tutorial we will a 2D function f(\mathbf{x},\mathbf{y}) and make a contour plot from it.

\left\{\begin{matrix}
f(\mathbf{x},\mathbf{y})=\sqrt{u}+x+y\\ 
u(\mathbf{x},\mathbf{y})=x^2+y^2
\end{matrix}\right.

while \mathbf{x}=\mathbf{y}=[0,0.1,0.2,0.3...,10]

Steps:

  1. Click the New Matrix button CreateNewMatrix.png to create a new matrix.
  2. To set the dimensions, select Matrix: Set Dimension/Labels from Origin menu menu, and set values as the image below, then click OK to apply:
    SetMatrixValue.png
  3. Then we are going to set values for the active matrix object to make it be u(\mathbf{x},\mathbf{y})=x^2+y^2
    • Select Matrix: Set Values from Origin menu. You can set values for Mat(1) in the opened dialog
    x^2+y^2
  4. Now add an extra matrix object to act as f(\mathbf{x},\mathbf{y})=\sqrt{u}+x+y, which will call Mat(1) in calculation.
    • Click the D button,Matrix d.png in the upper-left corner of matrix and choose Add from the context menu
    • Click the D button,Matrix d.png again and choose 2 to active the 2nd matrix object.
    • While the 2nd matrix object is active, set values for Mat(2) using formula below:
    sqrt(Mat(1))+x+y
  5. Finally, we can plot a contour graph from the Mat(2), which will be similar to this one:
    MatContourGrapg.png

Keywords: Contour, Matrix