how to generate text file from generated output
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 ?
0 Kommentare
Antworten (1)
J. Alex Lee
am 27 Feb. 2020
fprintf() accepts as 1st argument a file identifier for a file opened with fopen().
fid = fopen("somefile","w")
fprintf(fid,"mytext")
fclose(fid)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Import and Export finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!