I declare a global variable "A" in the base MATLAB workspace and assign it a value as follows:
global AA=1;
The workspace browser shows "A" is equal to 1. I open the variable "A" in the array editor and see that the correct value is displayed here as well. I assign a new value to "A" from the command line as follows:
A=2;
I see that both the workspace browser and the array editor show the correct value for "A". Now I modify "A" using an M -file function as follows:
function seta(x) global A A=x;
When I modify "A" using the function "seta", the Workspace Browser and Array Editor do not get updated with the correct value of "A". When I just type "A" at the Command Line the Array Editor updates, but the Workspace Browser does not. I need to right click in the Workspace Browser and select Refresh from the Context Menu to update the value of "A". If I assign a new value to "A" from the Command line as follows:
A=5;
both the workspace browser and the array editor will update correctly regardless of any updates I have made using "seta".
Best Answer