Can MATLAB workspace spreadsheets be updated while in a loop?

4 次查看(过去 30 天)
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 个评论
Arthur Nascimento
Arthur Nascimento 2018-8-24
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.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2018-8-24
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 个评论
THIVAGAR SUNDRARAJ
THIVAGAR SUNDRARAJ 2020-8-23
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.

请先登录,再进行评论。

更多回答(1 个)

Steven Lord
Steven Lord 2020-8-23
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.

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by