How to get the base workspace varibles in a function

Hey guys, the 'who' method only return the function argument. How to return the base workspace? Thank you so much`~~

 採用された回答

Kaustubha Govind
Kaustubha Govind 2011 年 12 月 13 日

1 投票

Do you mean that you just want to get the list of variables in the base workspace from your function? How about:
evalin('base', 'who')

3 件のコメント

Yuming Cao
Yuming Cao 2011 年 12 月 15 日
it works, in some way. but currently my work seems like moving all the base-workspace to my function-workspace can make my life easier, any way to do that?
Yuming Cao
Yuming Cao 2011 年 12 月 15 日
my workspace have many simulink.parameter, when i just type in the name of the parameter, it can return me this:
---
Simulink.Parameter (handle)
Value: 0
RTWInfo: [1x1 Simulink.ParamRTWInfo]
Description: ''
DataType: 'single'
Min: -Inf
Max: Inf
DocUnits: ''
Complexity: 'real'
Dimensions: [1 1]
---
I want this in my function space~~ How to do it ? Thank you ~~~
Yuming Cao
Yuming Cao 2011 年 12 月 15 日
I've already found out a way. it's efficient.
%run inside the function
evalin('base','save myvars.mat');
load myvars.mat;

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

その他の回答 (1 件)

Sean de Wolski
Sean de Wolski 2011 年 12 月 13 日

0 投票

[x y] = foo(r,s,t,u,v)
Calling from a script of the command line will pass base variables r,s,t,u,v into foo and return x,y to the base. Is this what you want? Note, foo has to be set up to take in various input arguments and return others.

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by