You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to demonstrate analysis time in app designer window ?
6 views (last 30 days)
Show older comments
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 ?
Accepted Answer
Ameer Hamza
on 25 Apr 2020
Text edit field will be more suitable. See the attached app.
31 Comments
farzad
on 27 Apr 2020
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
on 27 Apr 2020
Is this line inside a callback function? Can you share your file where this issue happen?
farzad
on 27 Apr 2020
well not the whole file, but yes, this line is inside a pushbutton
function ExecuteButtonPushed(app, event)
Ameer Hamza
on 27 Apr 2020
Then it should run as documented. Can you add the checkpoint at this line, and see if this line is executed.
Ameer Hamza
on 27 Apr 2020
You can find information about breakpoint here: https://www.mathworks.com/help/matlab/matlab_prog/set-breakpoints.html
farzad
on 27 Apr 2020
I did it,all variables are brought into workspace, except the problematic line
farzad
on 27 Apr 2020
Just nothing. since it comes from editfield into pushbutton callback, maybe I should create public property ?
farzad
on 27 Apr 2020
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
on 27 Apr 2020
app.AnalysisTimeEditField.Value
is the property of the app. It should update the edit field.
farzad
on 27 Apr 2020
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
on 27 Apr 2020
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
on 27 Apr 2020
Thank you very much. by the way, I have this question that is not being viewed, may you kindly check it ?
farzad
on 28 Apr 2020
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
on 28 Apr 2020
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 ?
farzad
on 1 May 2020
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
on 1 May 2020
Can you check the code browser pane? Are the callback functions still mentioned there?
farzad
on 1 May 2020
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
on 1 May 2020
If you go to the code view. You find the code browser pane on the left. See if those functions still exist here.
farzad
on 2 May 2020
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
on 2 May 2020
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
on 2 May 2020
I did, there it works. Simply. but not in my code !! even despite doing exactly the same thing
Ameer Hamza
on 2 May 2020
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
on 2 May 2020
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))
More Answers (0)
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)