How do you use one vector to name another vector?
古いコメントを表示
If you have three vectors: vect1 = [1 2], vect2 = [4 5], and vect3 = {'name1';'name2'}, how do I name vect1 and vect2 using the contents of vect3, i.e., how do I obtain
name1 = [1 2]
name2 = [4 5].
I have found one solution where the function assignin is used but I was wondering if there may be a more streamlined/simpler solution?
1 件のコメント
Image Analyst
2014 年 12 月 16 日
編集済み: Image Analyst
2014 年 12 月 16 日
And if you don't know the names in advance so that you can hard code in the variable name, and you have to create the variable dynamically from strings, then how are you going to be able to refer to name1 and name2 later in your code? Like you said, there is a simpler way to do whatever it is you want to do, and that way does not involve doing what you asked for. I completely agree with Star Strider there. Just let us know what you really need to accomplish and, rather than suggest a bad method like this yourself, let us advise you how to get you there.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Speed and Area Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!