How can I create a string vector?
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (1)
Azzi Abdelmalek
am 27 Dez. 2015
You can use cell arrays, for example:
planet={'planet1' 'planet2' 'planet3' 'planet4'}
vector=[2,4,3]
our=planet(vector)
Kategorien
Mehr zu Earth and Planetary Science finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!