---
title: "Example of modeling with MATLAB"
canonical: "https://help.vicon.com/space/Nexus215/11376343/Example%20of%20modeling%20with%20MATLAB"
format: markdown
---
> ⚠️ **Important**  
> ⚠️ The example MATLAB scripts work on normal gait (that is, overground walking) such as the gait trials in the sample data that is provided, and not on other walking types. If your data includes walking types that are atypical (for example, is not overground walking or requires cropping), ensure you copy the scripts and modify them as needed before running them on your trial data.

The following example uses a supplied MATLAB script (*SimpleMidpoint.m*), which is installed with Nexus 2 in the following default folder:

*C:\Program Files\Vicon\Nexus2.#\SDK\MATLAB\Examples*

This example script creates a marker mid way between two existing markers in a loaded trial, so you must specify the subject, the two markers between which to create the midpoint, and the name of the midpoint marker that is to be created.

**To execute a MATLAB script from within Vicon Nexus:**

1. In Nexus, open the trial on which the script is to run.
2. In the **Communications** window, click on the **Matlab** tab.
3. In the **Matlab script** field, enter or browse to the folder that contains the required MATLAB script (**.m*).
4. In the **Script arguments** field, if your script requires arguments, provide a comma-separated list of arguments to be used by the script, surrounding each argument for the subject and marker names with single quotes. The syntax is:  
`vicon, 'Subject Name', 'Marker1', 'Marker2', 'New Marker'`   
  
For the following example, you would enter:  
`vicon,'Colin','LWRA','LWRB','LWRM' `
  The supplied examples also show the required input and its format.
  > Macro (inline-media-image)

> Macro (inline-media-image)
  If your script does not require any arguments, leave the **Script arguments** field blank.
5. If you want to launch MATLAB and display your script, click the **Launch Matlab** button.
6. Click **Run Script**.  
Information, such as a time stamp and text describing the processing, together with any error messages, is displayed on the **Matlab** tab. Relevant information is also displayed in the **Log** pane.  
The modeled marker (in this case, the midpoint marker, LWRM) is created, and can be seen in the **3D Perspective** view.
  On the **Subjects Resources** pane, additional outputs are displayed under a newly created **Modeled Markers** node of the resources tree. In the following example, the new marker is called **MyMidpoint**.
7. Display a **Graph** view of the new marker to see that a trajectory for the new marker has been created for the whole trial.
8. If necessary, you can change your script in MATLAB and, to check that it has the desired result, run it again from either MATLAB or by clicking **Run Script** again.
9. When you have finished refining your script, to include it in a pipeline, click **Create Pipeline**, which copies the information you have supplied to a **Data Processing** pipeline operation, **Run Matlab Operation** in the **Pipeline** tools pane. The required inputs are displayed in the **Properties** pane.