strings to text file using num2str,strcat, and fprintf
이전 댓글 표시
I have been attempting to print data in vertical columns to a text file using the below format. I have tried about 30 different ways to get the formatting right, and am failing miserably. Any suggestion or help will be appreciated. I am fairly new at Matlab, and this was the explained procedure to get things to format correctly. I will be using real data and similar character arrays when it's all said and done.
A=['tr';'tr';'tr';'tr';'tr';'tr'];
B=randn([6 1]);
C=randn([6 1]);
D=randn([6 1]);
E=randn([6 1]);
F=randn([6 1]);
G=randn([6 1]);
H=randn([6 1]);
I=randn([6 1]);
D=strcat(A,num2str(B),num2str(C),num2str(D),num2str(E),num2str(F),num2str(G),num2str(H),num2str(I));
format='%s\r\n';
fileID=fopen('bs.txt','w');
fprintf(fileID,format,D')
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!