How to put these values into one array ?

1 回表示 (過去 30 日間)
Mohamed Ahmed
Mohamed Ahmed 2022 年 3 月 16 日
コメント済み: Mohamed Ahmed 2022 年 3 月 16 日
I have this vector X which is equal to
X =
Columns 1 through 8
1 2 3 4 5 6 7 8
I want to convert it into this format
X =
1, 2, 3, 4, 5, 6, 7, 8
How can I achieve this ?
  2 件のコメント
KSSV
KSSV 2022 年 3 月 16 日
Convert where? You want to write it into a text file?
Mohamed Ahmed
Mohamed Ahmed 2022 年 3 月 16 日
yes using fprintf

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

採用された回答

KSSV
KSSV 2022 年 3 月 16 日
x = 1:8 ;
f = [repmat('%d,',1,length(x)-1),'%d\n'] ;
fprintf(f,x)
1,2,3,4,5,6,7,8
  15 件のコメント
KSSV
KSSV 2022 年 3 月 16 日
x = logspace(log10(1),log10(10),10);
f = [repmat('%.4f,',1,length(x)-1),'%.4f'] ;
fprintf(fid,['frequency points = "', f,'";'],x);
Mohamed Ahmed
Mohamed Ahmed 2022 年 3 月 16 日
yess, this one worked.
Thank you!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by