Matlab is often used in conjunction with other software tools. The Modelit Directory Watcher activates a Matlab callback function each time the contents of a pre-specified directory change. This provides an easy and flexible mechanism to activate and feed data to Matlab from extrenal applications.

MATLAB CODE EXAMPLE

function main
%Example of usage of directory watcher
%specify exchange directory
wdir=fullfile(pwd,'extern2Matlab');
if ~exist(wdir,'file')
mkdir(pwd,'extern2Matlab');
end
DWG=dirWatcher('directory',wdir,'callb',{@xmlRespond});
start(DWG);

%directory watcher remains active untill figure is killed
figure('deletef',{@stopDirWatcher,DWG})

function xmlRespond(obj,event)
disp(sprintf('filename    = %s',get(event,'file')));
disp(sprintf('action      = %s',get(event,'type')));

function stopDirWatcher(obj,event,DWG)
%Stop and clear directory watcher
stop(DWG);
clear('DWG');