필터 지우기
필터 지우기

how to generate text file from generated output

조회 수: 1 (최근 30일)
Akshay Sahu
Akshay Sahu 2020년 2월 27일
편집: Akshay Sahu 2020년 2월 27일
A={{},{0 0;1 2;3 4;NaN NaN},{0 0;5 6;7 8;9 10;NaN NaN},{0 0;11 12;13 14;15 16;17 18;19 20;NaN NaN},{0 0;21 22;NaN NaN}};
SH = -.3;
n=450;
k=0;
s=size(A,2);
fprintf('%s%5.2f%s%5.2f%s%5.2f\n',T_11,A{1,2}{2,1},T_12,A{1,2}{2,2},T_13,(k))
for j=2:1:s
for i=2:1:(size(A{1,j},1)-1)
fprintf('%s%5.2f%s%5.2f%s%5.2f\n',T_11,A{1,j}{i,1},T_12,A{1,j}{i,2},T_13,SH*j-SH)
n=n+10;
end
j=j+1;
end
Above code gives output which is written below:
X 1.00Y 2.00Z 0.00
X 1.00Y 2.00Z-0.30
X 3.00Y 4.00Z-0.30
X 5.00Y 6.00Z-0.60
X 7.00Y 8.00Z-0.60
X 9.00Y10.00Z-0.60
X11.00Y12.00Z-0.90
X13.00Y14.00Z-0.90
X15.00Y16.00Z-0.90
X17.00Y18.00Z-0.90
X19.00Y20.00Z-0.90
X21.00Y22.00Z-1.20
I have to convert this output into a text file with .gcd extension how can I create ?

답변 (1개)

J. Alex Lee
J. Alex Lee 2020년 2월 27일
fprintf() accepts as 1st argument a file identifier for a file opened with fopen().
fid = fopen("somefile","w")
fprintf(fid,"mytext")
fclose(fid)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by