% function  TrackErrorZone(vt_acq_ent)

vt_acq_ent='VT1';
%variables used throughout this script
serverName = '129.116.146.244'; %the server we are going to connect with to get streaming data
% serverName = '192.168.0.1'; %the server we are going to connect with to get streaming data
%Replace this IP with the IP of the computer that is running Cheetah
vtXResolution = 640; %number of pixels of horizontal resolution for the video tracker
vtYResolution = 480; %number of pixels of vertical resolution for the video tracker
numberOfPasses = 10; %the number of times we will poll the server for new data before
%disconnecting and exiting the script
%Load NetCom into Matlab, and connect to the NetCom server if we aren’t connected
if NlxAreWeConnected() ~= 1
    succeeded = NlxConnectToServer(serverName);
    %Every NetCom function returns a value indicating if the command succeeded.
    %It is a good practice to check the succeeded value after every function call.
    %To keep the tutorial short, we will not do this for every function.
    if succeeded ~= 1
        fprintf('FAILED connect to %s. Exiting script.\r', serverName);
        return;
    else
        fprintf('Connected to %s.\r', serverName);
    end
end
%Identify this program to the server.
NlxSetApplicationName('Tracking Error Zones programme in Matlab');
%Get a list of all objects in Cheetah, along with their types. Then, check to see
%if the acquisition entities we want actually exist in Cheetah.
%It is a good practice to replace unused return values with ~, telling Matlab to
%ignore them. This both reduces memory usage and makes the program easier to read.
%For a complete list of return values, see the help for the function in question.
[~, cheetahObjects, ~] = NlxGetCheetahObjectsAndTypes();
if isempty(strmatch(vt_acq_ent, cheetahObjects))
    fprintf('FAILED the acquisition entity %s does not exist.\r', vt_acq_ent);
    %You should always disconnect from a server before terminating your script.
    NlxDisconnectFromServer();
    return;
end
% Open the data stream for the VT acquisition entity. This tells Cheetah to begin 
% streaming data for the VT acq ent.
NlxOpenStream(vt_acq_ent);