How do I update the workspace while a script is running in MATLAB?
I need my workspace to update every so often (like every X seconds) or (after a certai开发者_如何转开发n loop finishes).
Is there a command to update the workspace?
Added (4/1/11) while a script is running (it takes like 10 mins to run), I want to see what the values of the variables in the Workspace are doing
Not the exact answer to your question. I don't think it's possible, unless some undocumented feature exists.
I would advise you to use WHOS function to display workspace variables in run-time. You can do it not every iteration. Here is an example code to illustrate the point:
ivector=[];
for ii=1:100
ivector = [ivector ii];
pause(0.01)
if mod(ii,20)==0 %# do whos every 20th iteration
whos
end
end
You can show only certain variables with whos ivector
, for example.
Just don't put the semi-colon at the end, and it will print whatever variable:
while flag==0,
flux=flux*(1/(1-reactivity))
n=n+1;
if n>=20,
flag=1;
end
This will display flux every time it loops.
精彩评论