Trace variables of a function when executing
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
SAM Arani
el 11 de Sept. de 2022
Comentada: Walter Roberson
el 11 de Sept. de 2022
I have a matlab UI and it is desired to update the progressbar of this UI based on a variable which is being used in a running code ina function.
Consider below example:
%% a UI Code:
currentProg = min(round((size(wbar,2)-2)*(i/n)),size(wbar,2)-2);
RGB = app.processDataButtonHandle.Icon;
RGB(2:end-1, 2:currentProg+1, 1) = 0.25391; % (royalblue)
RGB(2:end-1, 2:currentProg+1, 2) = 0.41016;
RGB(2:end-1, 2:currentProg+1, 3) = 0.87891;
app.processDataButtonHandle.Icon = RGB; % (royalblue)
where
i
is a variable which shall be real time value of iterations in a for loop used in a function.
So, the whole code can be seen as:
%% a UI Code:
currentProg = min(round((size(wbar,2)-2)*(i/n)),size(wbar,2)-2);
RGB = app.processDataButtonHandle.Icon;
RGB(2:end-1, 2:currentProg+1, 1) = 0.25391; % (royalblue)
RGB(2:end-1, 2:currentProg+1, 2) = 0.41016;
RGB(2:end-1, 2:currentProg+1, 3) = 0.87891;
app.processDataButtonHandle.Icon = RGB; % (royalblue)
my_function(m,n,...)% other input variables
where in my_function() we have:
function my_function(m,n,...)% other input variables
for i=1:n
%% do some thing based on m
end
end
Do we have any possible way of updating that progress bar based on variable i which is in a for loop inside a function?
0 comentarios
Respuesta aceptada
Walter Roberson
el 11 de Sept. de 2022
No, not without the cooperation of the function being executed or using the debug facilities, or the cooperation of some function called by the target function
2 comentarios
Walter Roberson
el 11 de Sept. de 2022
The function itself could call waitbar(). Or a function that it calls could call waitbar(). Or you could use "dbstop at LINE if CONDITION" where you have coded CONDITION to invoke something that calls waitbar()
Note: there is an enhanced function that works like waitbar in the File Exchange, that also shows an estimate of time to completion
Más respuestas (0)
Ver también
Categorías
Más información sobre Dialog Boxes en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!