Can MATLAB workspace spreadsheets be updated while in a loop?

4 vues (au cours des 30 derniers jours)
Arthur Nascimento
Arthur Nascimento le 24 Août 2018
Commenté : Walter Roberson le 23 Août 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 commentaires
madhan ravi
madhan ravi le 24 Août 2018
could you upload your code?
Arthur Nascimento
Arthur Nascimento le 24 Août 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.

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 24 Août 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 commentaires
Arthur Nascimento
Arthur Nascimento le 24 Août 2018
That`s unfortunate, thanks anyway!
THIVAGAR SUNDRARAJ
THIVAGAR SUNDRARAJ le 23 Août 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.

Connectez-vous pour commenter.

Plus de réponses (1)

Steven Lord
Steven Lord le 23 Août 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 commentaire
Walter Roberson
Walter Roberson le 23 Août 2020
Though the original question asked not to use the debugger.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Compiler dans Help Center et File Exchange

Tags

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by