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 Commenti

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

Accedi per commentare.

Risposte (1)

KSSV
KSSV il 23 Giu 2022
A = [1 2 3] ;
dlmwrite('test.txt',A)

2 Commenti

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

Accedi per commentare.

Categorie

Prodotti

Release

R2021b

Richiesto:

il 23 Giu 2022

Commentato:

il 23 Giu 2022

Community Treasure Hunt

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

Start Hunting!

Translated by