Work on lab PC
- many new automations - scripts to record and save MPI and bias optimizations...
This commit is contained in:
45
Functions/updateWaitbar.m
Normal file
45
Functions/updateWaitbar.m
Normal file
@@ -0,0 +1,45 @@
|
||||
function updateWaitbar(currentIteration, totalIterations)
|
||||
|
||||
if currentIteration == 1
|
||||
|
||||
% Check if the waitbar already exists using its unique Tag
|
||||
hWaitbar = findobj('Tag', 'MyUniqueWaitbar');
|
||||
|
||||
if isempty(hWaitbar) || ~ishandle(hWaitbar)
|
||||
% Create a waitbar with a unique Tag if it doesn't exist
|
||||
hWaitbar = waitbar(0, 'Starting process...', 'Name', 'Processing Progress', 'Tag', 'MyUniqueWaitbar');
|
||||
else
|
||||
% Waitbar exists, reset the progress bar
|
||||
waitbar(0, hWaitbar, 'Resuming process...');
|
||||
end
|
||||
|
||||
elseif currentIteration == totalIterations+1
|
||||
% Check if the waitbar already exists using its unique Tag
|
||||
hWaitbar = findobj('Tag', 'MyUniqueWaitbar');
|
||||
|
||||
% Close the waitbar after the loop is completed
|
||||
if ishandle(hWaitbar)
|
||||
close(hWaitbar);
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
% Check if the waitbar already exists using its unique Tag
|
||||
hWaitbar = findobj('Tag', 'MyUniqueWaitbar');
|
||||
|
||||
% Calculate the progress fraction
|
||||
progressFraction = currentIteration / totalIterations;
|
||||
|
||||
% Update the waitbar's progress and message
|
||||
if ishandle(hWaitbar)
|
||||
waitbar(progressFraction, hWaitbar, ...
|
||||
sprintf('Progress: %d/%d', currentIteration, totalIterations));
|
||||
else
|
||||
% % If the waitbar was closed, recreate it
|
||||
% hWaitbar = waitbar(progressFraction, 'Resuming process...', 'Name', 'Processing Progress', 'Tag', 'MyUniqueWaitbar');
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user