Can MATLAB workspace spreadsheets be updated while in a loop?
4 views (last 30 days)
Show older comments
Arthur Nascimento
on 24 Aug 2018
Commented: Walter Roberson
on 23 Aug 2020
I have a differential evolution algorithm running in the bg, I want to sometimes pop in and look at the populations and fitness values, is there a way to do it without stopping the code with a breakpoint or without printing it to the command window?
2 Comments
Accepted Answer
Walter Roberson
on 24 Aug 2018
I want to know if, say I have this code:
a=0;
for i=1:50000
a=a+2;
end
There is a way to look at 'a' value while the loop is running and without debugging or printing 'a' to the command windows.
No, there is not. Using the debugger, or displaying data to the command window are your only option on current MATLAB releases.
With some older MATLAB releases (I think it might have been R2015a and earlier), there was an additional option, which was that the variable browser would, at unspecified times, get updated with current values of whatever workspace had been open at the time you executed. That is no longer the case: now the variable browser is only updated when the code is paused.
2 Comments
THIVAGAR SUNDRARAJ
on 23 Aug 2020
Hai Walter, thanks for your explanation cause i am having the same problem too. Im actually integrating visual c# with matlab program to develop the software system for my mobile robot. Im using Matlab of version 2019a and i need to put encoder data in workspace while matlab code is running. It has to happen in real time because in the while loop, the encoder data is constantly fetched and the motor speed is constantly computed and sent to visual c#. While matlab program is running, the code is c# is not able to put data in workspace. The data is only updated when code is paused which is not desired for the application.
More Answers (1)
Steven Lord
on 23 Aug 2020
As of release R2016a there is a button in the Editor that lets you pause running code and enter debug mode. It may take a little time to pause (if MATLAB is inside a call to a built-in function) and you may not pause exactly in the function or on the line you expect, but then you can use the debugging tools to step through the code to the place where the computations you want to check are performed.
1 Comment
See Also
Categories
Find more on MATLAB Compiler 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!