report values from my m. files as they are running back to my gui

1 view (last 30 days)
Hey, so I would like to be able to display iteration values and error next to each other in my gui as my m. file runs so that the user can see what iteration number the m.file is currently one and the level of error. Do i need to use a while loop in my gui m. file do update my text box continuously and use the handles format in my working m. file so that the info can be passed back and forth with out needing the working m. file to finish?
Thank you
  2 Comments
Image Analyst
Image Analyst on 2 Oct 2013
What error? If you get an error, it will throw an exception and create an error structure variable that will contain several pieces of information in it. If you want, you can catch it in a catch block and examine your iteration/loop variable at that time (before the function exits).

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 3 Oct 2013
I am going to guess that when you speak of "error" you are referring to something like iteratively calculating the value of a series, with the "error" being the difference between the calculated value and the known value.
How is your code currently set up? Do you currently have a routine that calculates exactly one additional iteration and returns the current value, and then you call the routine again for the next value? If you do then you probably already have a loop calling that function, and the place to update the gui would be where that work function is being called. set() a static text uicontrol 'String' property to display the string. Be sure to call drawnow() after you set() the property, to give the screen time to refresh with the new text.
If your existing code just has a single routine with a loop that does the iteration calculation in-line, then that loop is the place you should be doing the set() and drawnow()
  3 Comments
Walter Roberson
Walter Roberson on 3 Oct 2013
Yes, there is no difficulty doing that. Just be sure to drawnow() after you set() the String property of the uicontrol.
You might want to consider using waitbar(), which is more useful with a "for" loop, but sometimes can be meaningfully used with "while".

Sign in to comment.

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!