필터 지우기
필터 지우기

Calling Global value in a subroutine

조회 수: 1 (최근 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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Verification, Validation, and Test에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by