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 CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by