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 个评论

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.

请先登录,再进行评论。

回答(1 个)

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

2 个评论

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

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Text Data Preparation 的更多信息

产品

版本

R2021b

标签

提问:

2022-6-23

评论:

2022-6-23

Community Treasure Hunt

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

Start Hunting!

Translated by