ベースワークスペース​の変数を関数ワークス​ペース上で使用したい​のですが、どうすれば​よいですか?

21 Ansichten (letzte 30 Tage)
MathWorks Support Team
MathWorks Support Team am 24 Jan. 2013
ベースワークスペースの変数を関数ワークスペース上で使用したいのですが、どうすればよいですか?

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 24 Jan. 2013
EVALIN 関数が使用できます。
例えば、ベースワークスペースに次のように変数を定義します。
x_base = magic(2);
ここで、次のように MATLABファンクショファイル内に記述すると、ベースワークスペース上の変数 x_base を関数ワークスペース上の変数 x_local に割り当てることができます。
function myfun
x_local = evalin('base','x_base');

Weitere Antworten (0)

Kategorien

Mehr zu プログラミング finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!