# Quick Start

Here is an example including all key steps to show how easy for users to integrate matVis into their codes. There are only 6 lines of matVis codes in this example.

**Step 1** Initialize matVis:

```
call mvInit()
```

`mvInit()`

will initialize the matVis system and it must be called before any other matVis functions.

**Step 2** Data prepairing. Here is a 2d stucture surface data:

```
lx = 1.0; ly = 1.0
dx = 2*lx/(M-1); dy = 2*ly/(N-1)
do i=1,M; do j=1,N
x(i,j) = -lx + (i-1)*dx
y(i,j) = -ly + (j-1)*dy
z(i,j) = sin(x(i,j)**2 + y(i,j)**2)
enddo; enddo
```

**Step 3** Set settings of current subplot explicitly or simply use the default settings.

```
call mvSettings("3d{surfc:on;}")
```

`mvSettings`

will apply the settings to the objects added later until user changes these settints. In this example, the settings are `surfc:on`

, which means that surface contour will be shown for all the objects added later. In this example, a 2d structure surface object below is added.

**Step 4** Add an object to current subplot of matVis:

```
call mvS2d(h, M, N, x, y, z)
```

`mvS2d`

adds a 2d structure surface object in current subplot. Here we do not create figure window and subplot explicitly. matVis will create one automatically.

**Step 5** Pause to view the result:

```
call mvPause()
```

`mvPause`

will pause the code and wait until user clicks the `continue`

button in the tool bar.

**Step 6** Exit matVis and terminate the program:

```
call mvEnd()
```

`mvEnd()`

exits matVis and terminate the program. So the codes folloing `mvEnd()`

will be not reached.

### Result

After prepairing the code, compiling and running, we get

This is the complete code list:

```
program mvTest
implicit none
integer,parameter :: M=100, N=100
real lx, ly, dx, dy
real, dimension(M,N) :: x, y, z
integer h, i, j
lx = 1.0; ly = 1.0
dx = 2*lx/(M-1); dy = 2*ly/(N-1)
call mvInit()
do i=1,M; do j=1,N
x(i,j) = -lx + (i-1)*dx
y(i,j) = -ly + (j-1)*dy
z(i,j) = sin(x(i,j)**2 + y(i,j)**2)
enddo; enddo
call mvSettings("3d{surfc:on;}")
call mvS2d(h,M,N,x,y,z)
call mvPause()
call mvEnd()
end program mvTest
```