Convert cellarray with variables to cellarray of the variable names as strings
古いコメントを表示
Hi all,
I have a cell array as shown below, with different variables named as follows:
VarCell = {P_scav, T_exh, P_eng ... etc} ;
Is there a way to convert VarCell such that
VarCellChar = {'P_scav', 'T_exh', 'P_eng' ... etc} ;
In words, is there a way to convert VarCell's variable names in to a cell array with those variable names as strings?
Thanks in advance for your help,
KMT.
2 件のコメント
" is there a way to convert VarCell's variable names in to a cell array with those variable names as strings?"
Yes there are ways, but it is highly unlikely to be a good way to write code and solve your task:
What is the actual task that you are trying to achieve? I suspect your real task could be solved in a much better way, rather than relying on slow and buggy code that you are asking about:
For as start, it seems that you have put meta-data into your variable names. This is a bad design decision, because then accessing that meta-data can only be done using slow and complex methods. Much better is to store meta-data inside an array, as data in its own right. Then your task would also be much much simpler.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Entering Commands についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!