필터 지우기
필터 지우기

Matching value to corresponding variable via string name

조회 수: 1 (최근 30일)
Colin
Colin 2014년 8월 21일
답변: Honglei Chen 2014년 8월 21일
Hello All,
I am currently engaged in trying to create a new variable (ex. YO) which is equal to the value of another variable (ex. ANOTHER), however this must be carried out by only knowing a string which contains the second variable (i.e. ANOTHER). The example below should clarify:
ANOTHER=20;
myvec=('ANOTHER');
YO=f(myvec); %function which would make YO=20
Any assistance in how to build this "function" (not really a function file) would be greatly appreciated, as I've been stumped on this for about a day now!

채택된 답변

Honglei Chen
Honglei Chen 2014년 8월 21일
YO = eval(myvec)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by