Create cell array of numbers
36 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Steven Niggebrugge
il 16 Dic 2019
Commentato: Fatemeh Sadeghihassanabadi
il 30 Apr 2021
Hi,
how can i create a function that creates a cell array of number array 1:n, so the result is a cell array of string values.
so for example if i call that function s=f(1:10), it give me:
s = {'1','2','3','4','5','6','7','8','9','10'}
thanks so much!
0 Commenti
Risposta accettata
Guillaume
il 16 Dic 2019
Modificato: Guillaume
il 16 Dic 2019
This is dead easy if you are happy using the newish string type instead of char vectors:
s = string(1:10)
You can convert that to a cell array of char vectors, but you may as well continue using strings as they're easier to work with.
s = cellstr(string(1:10)) %if a cell array of char vector is really desired
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Type Conversion in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!