Hello Chandrasiri,
In MATLAB, when you are updating a GUI element such as a static text box within a loop, you might encounter an issue where the updates don't appear until the loop finishes. This happens because MATLAB's GUI updates are not automatically flushed to the screen during the loop execution. To force the GUI to update, you need to use the drawnow function.
Here is how you can modify your loop to ensure the static text updates after each iteration:
% Assuming you have a handle to your static text box, e.g., hStaticText
for i = 1:numIterations
% Your calculation code here
% Update the static text with the current iteration number
set(hStaticText, 'String', sprintf('Iteration: %d', i));
% Force MATLAB to update the GUI
drawnow;
end
To know more about this function, please follow this link: https://www.mathworks.com/help/matlab/ref/drawnow.html
I hope this helps!