Calling Global value in a subroutine

2 ビュー (過去 30 日間)
Jay
Jay 2016 年 10 月 1 日
コメント済み: Jay 2016 年 10 月 1 日
I have a subroutine script that requires a value from the master.
The master has a global specifier and is tied to a separate variable which obtains the value.
Ie.
global ObsNum
ObsNum = ObsArrayRow
The assumed global variable ObsNum returns the correct value in the workspace of the Master script.
The subroutine script then opens and continues executing and where I have stipulated:
n = ObsNum
The following error is thrown in the workspace:
"Undefined function or variable 'ObsNum'.
Error in AffineTransformationV1_0 (line 81) n = ObsNum
Error in Report3MainV1_0 (line 811) AffineTransformationV1_0() "
Do I need to do anything more to call the global variable ObsNum?

採用された回答

KSSV
KSSV 2016 年 10 月 1 日
編集済み: KSSV 2016 年 10 月 1 日
You have to use global ObsNum inside your function also. You declare the global variable inside the function.
  1 件のコメント
Jay
Jay 2016 年 10 月 1 日
Thanks Dr.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScope Variables and Generate Names についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by