Since MATLAB supports Java, it is straightforward to call CloudTurbine API methods from this package.  The first step is to add the CloudTurbine library (CTlib.jar) to MATLAB’s Java class path.  This library is available in the distribution file included with CloudTurbine releases.  Add this library to either the MATLAB “static path” or “dynamic path” (  Our recommendation is to add CTlib.jar to the static path.  Follow the instructions at to accomplish this.

Once CTlib.jar has been added to MATLAB’s Java class path and MATLAB has been restarted, you should be able to create CloudTurbine objects and call API methods.  As a test, try running the following in the MATLAB Command Window:

If MATLAB returns an error message such as

then the CloudTurbine library is not on MATLAB’s Java class path (double check the instructions above).

However, if MATLAB successfully created the CloudTurbine CTreader object you will see a message similar to the following:

The sample MATLAB function shown below fetches data output from CTmousetrack (part of CTexample.jar, included in  CTmousetrack saves the x,y position of your mouse to CloudTurbine files.  To display the mouse position in MATLAB: launch CTmousetrack; start MATLAB; call the sample function found below, giving it the full path to the parent folder which contains the CTmousetrack output source folder.  See the sample screenshot of the MATLAB plot showing mouse position below.

% Demonstrate calling CloudTurbine API from MATLAB
% Use this with the CTmousetrack sample program which has 2
% output data channels: x,y
% 2017-09-15 John P. Wilson, Erigo Technologies
% Input:  rootFolder  Full path to the folder which contains the
%                     CTmousetrack source folder

function displayMousetrack(rootFolder)
    % Import classes from the CloudTurbine CTlib library
    import cycronix.ctlib.*
    % Create CTreader
    ctr = CTreader(rootFolder);
    srcName = 'CTmousetrack';
    % Create the MATLAB axes
    hAxes = axes();
    hAxes.XLim = [0 1];
    hAxes.YLim = [0 1];
    hPlot = plot(hAxes,0,0);
    % Repeatedly fetch the newest 10 sec of CloudTurbine data and plot it
    % Note that CTmousetrack stores output data as comma-separated values,
    % therefore fetch it using getDataAsNumericF32()
    while true
        % Use CTreader.getData to fetch data, 1 channel at a time
        ctdata = ctr.getData(srcName,'x',0,10,'newest');
        time_x = ctdata.getTime();
        data_x = ctdata.getDataAsNumericF32();
        % Do absolute request for y (this will keep x,y channels time aligned)
        ctdata = ctr.getData(srcName,'y',time_x(1),time_x(end)-time_x(1),'absolute');
        data_y = ctdata.getDataAsNumericF32();
        % Make sure the arrays are the same length
        % If not, trim off right edge (newest data) of array (since we
        % should be aligned on oldest time in these arrays)
        len = min(length(data_x),length(data_y));
        if length(data_x) ~= len
            data_x = data_x( 1 : len );
        if length(data_y) ~= len
            data_y = data_y( 1 : len );
        % Display the data