How can I create a string vector?
Show older comments
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.
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 27 Dec 2015
You can use cell arrays, for example:
planet={'planet1' 'planet2' 'planet3' 'planet4'}
vector=[2,4,3]
our=planet(vector)
Categories
Find more on Earth and Planetary Science in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!