How to demonstrate analysis time in app designer window ?
1 次查看(过去 30 天)
显示 更早的评论
farzad
2020-4-25
Hi all
I have tic;toc in my code. How can I display the analysis time in an edit field as : hrs:minutes:seconds ?
should it be numeric or text edit field ?
采纳的回答
Ameer Hamza
2020-4-25
Text edit field will be more suitable. See the attached app.
31 个评论
farzad
2020-4-27
Thank you very much Ameer, I create an editfield value changed, and using the toc, nothing appears.
my main calculations are under a push button and when after the for loop I do :
app.AnalysisTimeEditField.Value = char(duration(0,0,toc));
nothing appears
Ameer Hamza
2020-4-27
Is this line inside a callback function? Can you share your file where this issue happen?
farzad
2020-4-27
well not the whole file, but yes, this line is inside a pushbutton
function ExecuteButtonPushed(app, event)
Ameer Hamza
2020-4-27
Then it should run as documented. Can you add the checkpoint at this line, and see if this line is executed.
Ameer Hamza
2020-4-27
You can find information about breakpoint here: https://www.mathworks.com/help/matlab/matlab_prog/set-breakpoints.html
farzad
2020-4-27
Just nothing. since it comes from editfield into pushbutton callback, maybe I should create public property ?
farzad
2020-4-27
Well I just got this window by hovering over the equation. The problem now is that this value does not move from push button function to the edit field function. I think one of the two sides of the equation should be a public property
Ameer Hamza
2020-4-27
app.AnalysisTimeEditField.Value
is the property of the app. It should update the edit field.
farzad
2020-4-27
I see the variable in WS as
AnalysisTimeEditField: [1×1 struct]
but the edit field is not updated : a point : I can click into this field and write in it. should it be like that ? am I using the write editfield or maybe the right setttings ?
Ameer Hamza
2020-4-27
I suggest you make a simple app with just a button and edit filed, that will make it easy to debug the issue. Because I cannot see any issue with the syntax, so this is likely some unrelated problem. I guess you are directly trying to update a pre-existing app. That is making it difficult to debug this issue.
farzad
2020-4-27
Thank you very much. by the way, I have this question that is not being viewed, may you kindly check it ?
farzad
2020-4-28
dear Ameer, I think this method works because you put the analysistime.Value under the StartUpFcn(app) function ,
I guess it will be different if you put it under pushbutton function. for simple cases it might work. but for my structure under pushbutton , after I finish a for loop, I do the toc
and matlab demostrates that value in workspace, the problem is that the value toc is not public property ( and I actually made it public property but it did not work again ), I mean I tried to assign the value by migrating toc under the editfunction value.
and also putting it under the pushbutton the editfield value does not update.
also : I have a close all command after that, does it do anything ?
farzad
2020-4-28
ok , there is clearly a difference, in your code, you have only one function for push button.
But in my code, I have one Value Changed function for the edit field , and then under the pushbutton function I try the line to change its value. aren't they overwriting ?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/288410/image.png)
farzad
2020-5-1
dear Ameer, since I still have not been successfull in applying this analysis time in my code :
strangely I can update a UITable contents from my calculation, so can't understand why this one is not working.
since I had created the edit fields a few times, their callbacks are left as junk in my code while I have deleted the editfield from interface. their names do not appear on component browser but I see the function in the code and it's not ediable any solution to this ?
Ameer Hamza
2020-5-1
Can you check the code browser pane? Are the callback functions still mentioned there?
farzad
2020-5-1
what do you mean by code browser pane ? where I write the code ? Yes ! Exactly and that's the problem that I can not solve.those functions can not be deleted from the code
Ameer Hamza
2020-5-1
If you go to the code view. You find the code browser pane on the left. See if those functions still exist here.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/289471/image.png)
farzad
2020-5-2
Thank you ! yes ! this was resolved.
I tried to create it again, without callback, and only used its handle. actually it correctly gets the value when I use break point to check the parameters :
K>> app.AnalysisTimeEditField
ans =
struct with fields:
Value: '00:22:06'
but it is not demonstrated on the Edit Field. I don't know what is preventing it.
the structure of my code is :
if condition
tic
for
try
CatchME
end
end
end
close all
app.AnalysisTimeEditfield= char(duration(0,0,te))
Ameer Hamza
2020-5-2
Can you create a new app and try with just an edit field, without any other elements. If it still does not work, please attach the smaller app so that I can inspect it to find the problem.
farzad
2020-5-2
I did, there it works. Simply. but not in my code !! even despite doing exactly the same thing
Ameer Hamza
2020-5-2
Without inspecting the actual app, there is not much that can be done. As you have also observed that it works in a standalone app. So there must be some other thing in that app that is preventing that.
farzad
2020-5-2
All I have after finishing the loop :
te=toc
waitbar(1, h1, 'msg')
close all
h2 = waitbar(1,'msg');
app.EditField_7.Value = char(duration(0,0,te))
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)