Re-read the variable name
이전 댓글 표시
Hello Everyone,
I have alloted 5 variable names to 5 different 15x1 matrix, for example.
ec=data(:,1);
fe=data(:,2); and so on for Co3, Ca and Na
then I am merging all the data into variable x for some calculation so we get x=15x5 matrix. Now after the calculation I get an answer which is one of 5 different 15x1 matrix. Then how to get the variable name as an answer. Like the code should tell that the answer is either ec, fe, Co3, Na or Ca. Means the code should read the variable name which I have assigned in the very starting of the code.
Thanks in advance.
댓글 수: 3
Using ec, fe, etc. variable names is most likely a red herring. Just use data directly, and then afterwards use indexing to select the names from a string array or a cell array of character vectors.
V = ["fe","ce",...]; % string array
V(idx)
Prakhar Modi
2019년 8월 16일
Walter Roberson
2019년 8월 16일
Stephen's V variable can easily be extended to hold 17 names
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!