storing matrix elements in a single variable as string
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Karanvir singh Sohal
le 29 Mar 2021
Commenté : Karanvir singh Sohal
le 29 Mar 2021
Hello!
I want to join the multiple int from the matrix and save them as a string. Let us say I have a matrix A.
A = [3 25 100 5 20 100];
I want to store these values in B as following
B=("3#25@100","5#20@100")
Thanks in advance.
0 commentaires
Réponse acceptée
Fangjun Jiang
le 29 Mar 2021
Use for-loop if want to split
A = [3 25 100 5 20 100];
>> B=sprintf("%d#%d@%d\n",A(:))
B =
"3#25@100
5#20@100
"
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Characters and Strings 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!