MATLAB: Waitbar till a file is created after a process

guiminimization processnot defined stepwaitbar

Dear all, I have a minimization function with many nested functions, inside a matlab gui. This function starts after pressing a button. So, you realise that the time for the minimization process to end is not defined. When the minimization is ended a figure is exported! Does anyone know how to create a waitbar to count till the figure creation??? All waitbars need a loop with a step. However, the time for the minimization is different each time! Thank you!
Related Question