Why doesnt the workspace show the variables?
1 view (last 30 days)
Show older comments
I run the programme, it ends without any problem. Also with whos command i can see the variables in command window. But workspace doesnt show anything, Also after finishing the run process, i write the variable to the command window but it says undefined variable. Do you know what is the problem? I need to see the variables content from workspace.
Accepted Answer
Shane
on 19 Sep 2012
Function programs often run through dozens, if not hundreds, of variables before reaching a desired output as designated by the writer. Check the text of the code to determine if the variables you are looking for are output variables. Below is an arbitrary example:
[value1 value2] = function(x)
internalVariable = x * cos(x+10);
value1 = sin(internalVariable)
value2 = tan(internalVariable)
In this code, value1 and value2 are output and will be moved to the workspace. The internalVariable will not be placed in the workplace because it is not designed to be part of the function output. If you would like to make sure the variables are being output into the workspace change the function line to look like this:
[value1 value2 internalVariable] = function(x)
Then when you run the function with three output requests, you will obtain the desired variable in the workplace.
The other way to obtain all the internal variables without editing the code is to run the function within the cell mode in the editor using Ctrl+Enter. This will put all of the internal variables into the workspace.
Hope this helped!
2 Comments
sun
on 9 Jul 2020
@Shane ,@Hande
I encountered the same problem,
First, the version of Matlab I use is R2017a.
(1) When executing a custom function (no return value), the program can display the variables inside the function in the workspace.
(2) After I reinstalled matlab (R2017a), no variables are displayed when the same function is executed.
How can I solve it?
More Answers (0)
See Also
Categories
Find more on Workspace Variables and MAT-Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!