Can MATLAB workspace spreadsheets be updated while in a loop?

4 views (last 30 days)
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
Arthur Nascimento
Arthur Nascimento on 24 Aug 2018
Sorry if I sound rude but I don't know how is that pertinent to the question. 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. Since I need to look at many matrices and variables so printing would be a mess and, the code takes a long time to run so pausing the loop would be bothersome.

Sign in to comment.

Accepted Answer

Walter Roberson
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
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.

Sign in to comment.

More Answers (1)

Steven Lord
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.

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Tags

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!