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 件のコメント

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

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2022 年 6 月 23 日

0 投票

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

2 件のコメント

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

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeText 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