Simplest way to save a vector to a variable with commas and braces
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vinay Killamsetty
le 27 Fév 2020
Commenté : Stephen23
le 1 Mar 2020
How a can I save a numeric vector a= 1 2 3 4 5
as [1,2,3,4,5] (braces and commas are to be added here)
with a simple solution
0 commentaires
Réponse acceptée
Stephen23
le 27 Fév 2020
Modifié(e) : Stephen23
le 27 Fév 2020
You can create a character vector:
>> strrep(mat2str(a),' ',',')
ans = [1,2,3,4,5]
which you can save however you want. But this is unlikely to be useful, or a good approach to saving data.
2 commentaires
Stephen23
le 1 Mar 2020
The follow-up question
indicates that using standard binary/text file formats would be much simpler than this pointlessly complex way of encoding data.
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Whos dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!