Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8049733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:51:55+00:00 2026-06-05T06:51:55+00:00

I need to perform data analysis on files in a directory as they come

  • 0

I need to perform data analysis on files in a directory as they come in.

I’d like to know, if it is better,

  1. to implement an event listener on the directory, and start the analysis process when activated. Then having the program go into sleep forever: while(true), sleep(1e10), end

  2. or to have a loop polling for changes and reacting.

I personally prefer the listeners way, as one is able to start the analysis twice on two new files coming in NEARLY the same time but resulting in two events. While the other solution might just handle the first one and after that finds the second new data.
Additional idea for option 1: Hiding the matlab GUI by calling frames=java.awt.Frame.getFrames and setting frames(index).setVisible(0) on the index matching the com.mathworks.mde.desk.MLMainFrame-frame. (This idea is taken from Yair Altman)

Are there other ways to realize such things?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:51:56+00:00Added an answer on June 5, 2026 at 6:51 am

    In this case, (if you are using Windows), the best way is to use the power of .NET.

    fileObj = System.IO.FileSystemWatcher('c:\work\temp');
    fileObj.Filter = '*.txt';
    fileObj.EnableRaisingEvents = true;
    addlistener(fileObj,'Changed',@eventhandlerChanged);
    

    There are different event types, you can use the same callback for them, or different ones:

    addlistener(fileObj, 'Changed', @eventhandlerChanged );
    addlistener(fileObj, 'Deleted', @eventhandlerChanged );
    addlistener(fileObj, 'Created', @eventhandlerChanged );
    addlistener(fileObj, 'Renamed', @eventhandlerChanged );
    

    Where eventhandlerChanged is your callback function.

    function eventhandlerChanged(source,arg)
       disp('TXT file changed')
    end
    

    There is no need to use sleep or polling. If your program is UI based, then there is nothing else to do, when the user closes the figure, the program has ended. The event callbacks are executed exactly like button clicks. If your program is script-like, you can use an infinite loop.

    More info in here: http://www.mathworks.com/help/matlab/matlab_external/working-with-net-events-in-matlab.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to perform data validation of two tables using Selenium . Given a
I need to perform update/insert simultaneously changing structure of incoming data. Think about Shops
I'm developing an application through Core Data and I need to perform some calculation
Is it better to perform data access operations on the page and then populate
I have a set of data on which I need to perform a topological
I need to perform video scaling in my C++ app. I know I can
I need to implement a daemon that needs to extract data from a database,
I need to perform normalization on data structure. I have one table with lots
I need to perform a search in two different data structures in C#, and
I need to perform an ajax request to send some data server-side every time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.