comma insertion in array

I would like to add commas between array values.
for example, I have a array A.
A = [1 2 3];
I would like to get a list of B from A.
B = [1, 2, 3];
How can I do this?

4 commentaires

KSSV
KSSV le 23 Juin 2022
You want to write B in text file? Why you want commas? What's the purpose?
병극 조
병극 조 le 23 Juin 2022
Yes, I want to write B in text file.
Thank you.
Rik
Rik le 23 Juin 2022
Just to clarify: A is a Matlab variable, and B should be the char vector '[1, 2, 3]'?
병극 조
병극 조 le 23 Juin 2022
no type change. I just want to put commas.
Thank you.

Connectez-vous pour commenter.

Réponses (1)

KSSV
KSSV le 23 Juin 2022

0 votes

A = [1 2 3] ;
dlmwrite('test.txt',A)

2 commentaires

병극 조
병극 조 le 23 Juin 2022
This is what I want. Thank you very much.
KSSV
KSSV le 23 Juin 2022
Thanks is accepting/ voting the answer. :)

Connectez-vous pour commenter.

Catégories

Produits

Version

R2021b

Tags

Question posée :

le 23 Juin 2022

Commenté :

le 23 Juin 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by