How can I create a string vector?
显示 更早的评论
Given a vector containing a certain number of elements, for example vector=[2,4,3], I have to create a vector containing in each row (or column) the name of the corresponding planet in the solar system. In the case of the previous vector, the result should be PlanetName=['Venus';'Mars';'Earth']. Can you suggest me a method to create such a vector? thank you.
采纳的回答
更多回答(1 个)
Azzi Abdelmalek
2015-12-27
You can use cell arrays, for example:
planet={'planet1' 'planet2' 'planet3' 'planet4'}
vector=[2,4,3]
our=planet(vector)
类别
在 帮助中心 和 File Exchange 中查找有关 Earth and Planetary Science 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!