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 Comments

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

Sign in to comment.

Answers (1)

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

2 Comments

This is what I want. Thank you very much.
Thanks is accepting/ voting the answer. :)

Sign in to comment.

Categories

Products

Release

R2021b

Tags

Asked:

on 23 Jun 2022

Commented:

on 23 Jun 2022

Community Treasure Hunt

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

Start Hunting!