> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ntop.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Running nTop Automate in Matlab scripts

## Objective:

Learn how to run your nTop notebook using nTop Automate (ntopcl) in Matlab scripts.

## Procedure:

* [Prepare the nTop notebook](/help-articles/knowledge-base/ntop-automate/preparing-an-ntop-notebook-for-ntop-automate) and JSON input for running nTop Automate
* Matlab Struct data structure can read, modify and write JSON input files.
* **Run (F5)!**
* Check if the return messages are printed as below.

```
[info] Logging Engine started
[info] Login successful[info] Parasolid started
[info] Parasolid started
[info] nTop successfully built.
[info] Logout successful

```

Feel free to change this script to batch-process your workflow by passing input lists in a loop!

```
clc,clear,close all

%Provide file paths to nTopCL, nTop file, and output JSON file
%Assuming input and output JSON files as well as .ntop file in the same folder
pathToExe = ['"' 'C:\\Program Files\\nTopology\\nTopology\\ntopcl.exe' '"'];
FileToRun='SampleFile.ntop';
OutputFile='output.json';

%Provide a input JSON file
InputFile='input.json';
Inputs = jsondecode(fileread(InputFile));

%Modify input variables
Inputs(1).inputs{2,1}.values = 5;
Inputs(1).inputs{3,1}.values = 3;
Inputs(1).inputs{4,1}.values = 2;

%Write JSON file
JsonStr = jsonencode(Inputs);
JsonStr = strrep(JsonStr, ',', sprintf(',\r'));
JsonStr = strrep(JsonStr, '[{', sprintf('[\r{\r'));
JsonStr = strrep(JsonStr, '}]', sprintf('\r}\r]'));
fid = fopen(InputFile, 'w');
if fid == -1, error('Cannot create JSON file'); end
fwrite(fid, JsonStr, 'char');
fclose(fid);

%Compose a execution command
Arguments=sprintf('%s -j %s -o %s %s', pathToExe,InputFile,OutputFile,FileToRun);
%Run
system(Arguments);
```

And that's it! You've successfully run nTop Automate using Matlab scripts.

Are you still having issues? Contact the [support team](https://support.ntopology.com/hc/en-us/requests/new), and we'll be happy to help!

## Download the Example file:

* [Sample File](https://ntopology.box.com/s/6x5vbjet9d1ozna2hnvr9fd8cthje181)
* [input.json](https://ntopology.box.com/s/sotpx3s44vwrx8su6n6yjxr058komng5)
* [Script\_JSON.m](https://ntopology.box.com/s/qc4dkwvvqbdhl9nz63xe9tngzhlnjjpu)

## Keywords:

*ntop output ntopcl command line api script matlab input command run code cl lab*
