MATLAB: Possible Codes for GUI pushbutton!!!

gui button

i will like a button on my GUI when clicked on, to run and exe file in folder on my computer. Please can anyone help me with possible codes to use so my button can perform this task?

Best Answer

  • function pushbutton1_Callback(hObject, event, handles)
    filedir = pwd;
    exedir = pwd; %not necessarily the same as where files are
    exename = 'gusprime.exe';
    exefullname = fullfile(exedir, exename);
    fileinfo = dir(fullfile(filedir, '*.dat'));
    filenames = fullfile(filedir, {fileinfo.name});
    numfiles = length(filenames);
    for K = 1 : numfiles
    thisfile = filenames{K};
    cmd = sprintf('"%s" /some /options /here "%s"', exefullname, thisfile);
    [status, message] = system(cmd);
    if status == 0
    fprintf('Okay processing file "%s"\n', thisfile);
    else
    fprintf('Error processing file "%s", message was "%s"\n', thisfile, message);
    end
    end