How do I view the function workspace?

I have several functions in my script. When I run the script, the variables do not show up in the base workspace. I don't know how to view the function workspace, hence I can't see the values of my function variables.

3 件のコメント

Shubham Maurya
Shubham Maurya 2016 年 6 月 3 日
This is the difference between global and local variables. Global variables are accessible throughout the program whereas local variables can be accessed only in the function body.
Walter Roberson
Walter Roberson 2016 年 6 月 3 日
global variables are accessible only in routines that also declare the variable to be global.
daniel
daniel 2017 年 1 月 30 日
brake point and step in to the function, will show everything

サインインしてコメントする。

 採用された回答

Sean de Wolski
Sean de Wolski 2014 年 6 月 18 日

0 投票

Your answer with the breakpoints is the best one. Another way would be to use the whos command inside of the function:
whos

その他の回答 (1 件)

Image Analyst
Image Analyst 2014 年 6 月 18 日

0 投票

Put this command as a line in your script or function
workspace;

5 件のコメント

Adwait
Adwait 2014 年 6 月 18 日
I put it in the function but it still doesn't show me the variables.
I found another way. If I set a breakpoint in the function it shows the function workspace.
If you know of another way of doing this it would be great if you could share.
José-Luis
José-Luis 2014 年 6 月 18 日
I'm not entirely sure what you want, but you could have the function return the variables you are interested in.
Adwait
Adwait 2014 年 6 月 18 日
That's true. The workspace is just a convenient place to look at the value and the other attributes. Thanks.
Jeff Bull
Jeff Bull 2021 年 11 月 18 日
Having the same issue but adding workspace; to the .m file did not work. still cannot see the variables of the function from the command line.
Image Analyst
Image Analyst 2021 年 11 月 18 日
@Jeff Bull, do you see the workspace panel? If it was not up, then calling worskapce should show it. And it should show the current values of the variables. If it can't show them all in the workspace, you can double click on the variable name in the workspace to bring it up in the variable editor where you'll be able to see more values of it.
If you set a breakpoint on the line where you call your function you should see in values of the input arguments both in the workspace panel, and in a popup when you hover your cursor over the variables in the source code panel. Are you saying that neither of these methods display the values? Worst vase you can double click the variable name (to select it) and type F9 to show it in the command window, or you can just type the name on the command line.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeWorkspace Variables and MAT Files についてさらに検索

製品

タグ

質問済み:

2014 年 6 月 18 日

コメント済み:

2021 年 11 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by