Call an array by a string

조회 수: 3 (최근 30일)
aboudeh kahaleh
aboudeh kahaleh 2016년 10월 24일
댓글: Guillaume 2016년 10월 24일
Hello,
in my code i need to call the array [0,0,1] by the string 'cup1' how can i do that?
Thank you so much!!
  댓글 수: 1
Guillaume
Guillaume 2016년 10월 24일
It's not very clear what you're trying to do, particularly the motivation. I assume you're not asking for
cup1 = [0, 0, 1];
Hopefully, you're not asking how to name your variable dynamically as it's a very bad idea. Again, explain what you want to do and more importantly why.

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2016년 10월 24일
k = [0,0,1] ;
cup1 = num2str(k) ;

카테고리

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