MATLAB GUI does not finish execution when called from another MATLAB based GUI.

2 ビュー (過去 30 日間)
Hi Everyone,
I have a MATLAB R2020b gui based application which basically is a menu with buttons and each button press is another MATLAB GUI based executable. The problem is that when I run the main wrapper GUI and press a button, it successfuly launches the executable associated with that. The inner gui based executable is supposed to interface with HW and collect data, save and close and return back the execution to the main GUI. However the problem is that once the inner gui executable saves the data using the save function, it somehow gets frozen, hangs. Nothing happens.
Now here are some other strange observations.
  1. When I run the same deployed setup with extended screens connected to my laptop, it works.
  2. When I run the inner gui directly by double clicking it instead of calling it as a button press from the outer gui, it works.
  3. If I comment out the save function inside the inner GUI, the data doesn't get saved but the program executes and it works.
I have not been able to undestand this weird behavior. Has someone encountered this behavior before ?
Here is the code inside the launcher.exe that executes on a button press and calls another GUI (executbable)
function abc_Callback(hObject, eventdata, handles)
handles.abc.Enable = 'off';
pause(0.2)
try
executablePath = fullfile(handles.rootdirectory, 'folder1', 'folder2', 'abc.exe');
command = sprintf('"%s"', executablePath);
[status] = system(execFileNameWithExt);
catch e
disp(e)
end
handles.abc.Enable = 'on';
Also here is where the save function is run. I added some debug lines before and after the save function and realized that
msgbox('calling "save" function inside generatereport');
save(fullfile(res.Report.reportDir,reportName),'res');
msgbox('executed the "save" function inside generatereport, now on line 99');
now the 2nd msgbox never gets executed. However the save function does save the res object currently at the desired location.
How do you think I should try to debug this problem ? Should i use the logs ?

採用された回答

Hassaan
Hassaan 2024 年 7 月 23 日
編集済み: Hassaan 2024 年 7 月 23 日
Few of the possible debugging steps may help:
Check File Permissions:
Ensure the save directory has the necessary permissions and is not being accessed by another process.
Simplify the Save Operation:
Test saving a simple variable to a different location to see if the issue persists.
If res is a large object, saving it might take a considerable amount of time or memory. Try saving a smaller subset of res to see if that works.
Debug the Save Function:
Add more debug messages around the save function to isolate the problem.
Log Files:
Use diary or similar logging to create a log file for tracking execution.
System Commands:
Ensure the system call does not interfere with MATLAB execution. Add debugging for system call status and output.
function abc_Callback(hObject, eventdata, handles)
handles.abc.Enable = 'off';
pause(0.2);
try
executablePath = fullfile(handles.rootdirectory, 'folder1', 'folder2', 'abc.exe');
command = sprintf('"%s"', executablePath);
disp(['Executing: ', command]);
% Use system command and capture status and output
[status, cmdout] = system(execFileNameWithExt);
disp(['Status: ', num2str(status)]);
disp(['Command Output: ', cmdout]);
catch e
disp(e)
end
handles.abc.Enable = 'on';
end
Screen Configuration:
Check display settings as the issue might be related to extended screens.
Resource Monitoring:
Use the task manager to monitor resource usage during execution.
MATLAB Updates:
Consider updating to a newer MATLAB version.
Save in Different Format:
Try saving with -v7.3 for large data handling.
Parallel Processing:
Ensure proper configuration if using parallel processing.
  1 件のコメント
Pratik Chachad
Pratik Chachad 2024 年 7 月 26 日
Thank you @Hassaan. Simplifying the save operation does seem to help but its weird why it works when run as a standalone application but fails when executed from the wrapper

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by