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

  • SEARCH
  • Home
  • 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 6797677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:38:17+00:00 2026-05-26T18:38:17+00:00

I have written a Matlab GUI for my C program. I thought about using

  • 0

I have written a Matlab GUI for my C program. I thought about using MEX, but there are too many C files and C program requires a DLL to run.

So, instead I have the Matlab System function calling the executable with inputs, something like [status results] = system('executable "input 1" "input 2"'), which runs well, but I want real time output. results is just a percent output of how complete the program is, and I want to use this output for a GUI progress bar in Matlab.

The output does get stored into results, but only after the program is complete. Thus, making the progress bar pointless.

Is it possible to get the executable to send outputs one at a time to Matlab, and then have Matlab update the progress bar, and return to the executable?

Edit: I’m looking for a solution in Windows.

  • 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-05-26T18:38:18+00:00Added an answer on May 26, 2026 at 6:38 pm

    I found a solution. Credit goes to Richard Alcock at Matlab Central

    Specifically, for my solution:

    cmd = {'executable.exe', 'input 1', 'input 2'};
    processBuilder = java.lang.ProcessBuilder(cmd);
    cmdProcess = processBuilder.start();
    
    % Set up a reader to read the output from the command prompt
    reader = 
        java.io.BufferedReader(...
            java.io.InputStreamReader(...
                cmdProcess.getInputStream() ...
            ) ...
        );
    
    % Loop until there is some output
    nextLine = char( reader.readLine );
    while isempty(nextLine) 
        nextLine = char( reader.readLine );
    end
    
    % Then loop until there is no more output
    while ~isempty(nextLine);
        fprintf('Output: %s\n', nextLine);
        nextLine = char( reader.readLine );
    end
    
    % Get the exit value of the process
    exitValue = cmdProcess.exitValue  
    

    Note: this code does not hold up the executable. The executable must finish before this code finishes, otherwise this code crashes when it gets ahead of the executable.

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

Sidebar

Related Questions

Have written some RoR sites in the past, but never bothered too much at
I have written some piece of code for my program in Matlab 7.10.0 which
I have a series of experiments that were written for MATLAB, but recently we
I have written a simple brainfuck interpreter in MATLAB script language. It is fed
I'm trying to rewrite code I've written in matlab in C++ instead. I have
I have written a site in Prototype but want to switch to jQuery. Any
I have written the following code in MATLAB to process large images of the
I've written a very simple GUI in MATLAB that will convert temperatures. It is
I have this line of code in MATLAB, written by someone else: c=a.'/b I
Assume I have written a function fun(a,b,c) in Matlab and saved it ..\My Documents\MATLAB\fun.m

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.