function importfcn % wait an extra second to ensure that the file modification is complete
pause(1.0); % read the data from file
fileToRead = fullfile('C:\Users\wolfgang\Desktop\file1.csv'); circa = xlsread(fileToRead); kevin=0.5*(circa(:,4)+circa(:,5)).' assignin('base','kevin',kevin) % do something with the data
endfsw = System.IO.FileSystemWatcher();fsw.Path = 'C:\Users\wolfgang\Desktop';fsw.Filter = 'file.csv';fsw.EnableRaisingEvents = true;listenerhandle = addlistener(fsw, 'Changed', @importfcn);%signature of importfcn is function importfcn(sender, eventargs)
%add a small delay in importfcn before reading the file as the event is raised
%to make sure that file modification is complete
Then I get the following error: Warning: Error occurred while executing callback: Error using importfcn Too many input arguments.
Warning: Error occurred while executing callback: Error using importfcn Too many input arguments.
When I type in importfcn then everything is ok and the file gets imported as variable kevin.
Best Answer