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 个评论
采纳的回答
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
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
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.
1 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!