How to get calculations in workspace from GUI?

1 view (last 30 days)
Hi, I have developed a GUI where user will give inputs. The complete calculation is iterated till 2400 seconds. Now I get only final output. I want to get values for each step in workspace like when we run a .m file. How to do that?

Accepted Answer

Geoff Hayes
Geoff Hayes on 17 May 2015
Edited: Geoff Hayes on 17 May 2015
Adi - instead of writing your variables to the workspace, why not just save the results (of the 2400 seconds) to a mat file using save? I think that may be a cleaner approach. Or is there a particular reason why you want to try and access this data from the workspace?
  2 Comments
adi kul
adi kul on 18 May 2015
Hi Geoff, I found an bug in my results. The results after calculations are not coming as I have expected. So I wanted to know which calculation is a culprit. I have more than 75 equations interlinked with each other and It's very complicated code to check each and every equation. So by getting results for the equations on workspace, I can see which variable is crossing it's limit and hence giving wrong end result.
As I run my gui, it only gives end result but no variable's values in workspace.
I hope you got my question and requirement.
Stephen23
Stephen23 on 18 May 2015
Edited: Stephen23 on 18 May 2015
Each function already has its own workspace, and it is easy to look at the variables inside any workspace using the debugging tools. Although it sounds like a great idea to move everything to the main workspace just to have a look at it, it is much more robust and efficient to use the debugging tools to look at the data exactly in the workspace where it is. This has multiple advantages, including smaller memory usage, ability to trigger based on events of conditions, ability to run arbitrary code in the middle of code execution and the fact that the code stays unchanged.
Learn how to use MATLAB's programming tools and your own life gets much easier and more productive. In your case, where the output is not what you expect, you could use the breakpoints with conditions.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!