필터 지우기
필터 지우기

Trace variables of a function when executing

조회 수: 3 (최근 30일)
SAM Arani
SAM Arani 2022년 9월 11일
댓글: Walter Roberson 2022년 9월 11일
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?

채택된 답변

Walter Roberson
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
SAM Arani
SAM Arani 2022년 9월 11일
can I have examples of introduced ways?
I'm not so sure about the ways you mentioned but the debug facilities.
What do you mean by cooperation of the funtion or the functions called by the target function?
Walter Roberson
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 CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by