Trace variables of a function when executing
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Walter Roberson
2022 年 9 月 11 日
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 件のコメント
Walter Roberson
2022 年 9 月 11 日
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
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Dialog Boxes についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!