Convert Cell to variable name array
조회 수: 46 (최근 30일)
이전 댓글 표시
How can i use cell text as variable name input?
I want to use string variables "A" as variable name to output"B".
A={'sample1' 'sample 2' 'sample3'}
like this:
[B]=[sample1, sample2, sample3]
please suggest code made for 2013 matlab version.
Thanks for your help!
댓글 수: 6
madhan ravi
2019년 5월 17일
편집: madhan ravi
2019년 5월 17일
The creation of those matrices are not a good idea , if the sizes are consitent use a ND array else use a cell array as is, what your doing is risky and vulnerable. Don't believe see the valuable contributions
채택된 답변
madhan ravi
2019년 5월 17일
A={'sample1' 'sample2' 'sample3'} ;
a = array2table(rand(3)); % an example
a.Properties.VariableNames=A
댓글 수: 7
Stephen23
2019년 5월 19일
Rather than this complex and inflexible code:
sample1=patie2(:,1)
sample2=patie2(:,2)
sample3=patie2(:,3)
sample4=patie2(:,4)
patie = table(time,sample3,sample4,sample2,sample3);
just use array2table. In fact it seems like most of your code could be replaced by array2table and a few table operations.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!