Save file .txt in desktop
이전 댓글 표시
Hello, I want to save a file with the format .txt in my desktop, not in matlab/Work. This is my program:
clear all;
Name_file=input('Tell me the name of the file(example.dat): ','s');
X=[ 0 0.5 0.75 1];
Y=[ 0 1 2 3];
A=[X' Y'];
[n,m]=size(A);
fid=fopen(Name_file,'w');
for i=1:n
for j=1:m
fprintf(fid,'%8.4f\t',A(i,j));
end
fprintf(fid,'\n');
end
fclose(fid);
채택된 답변
추가 답변 (1개)
Xenxo
2011년 8월 16일
0 개 추천
댓글 수: 1
Fangjun Jiang
2011년 8월 16일
All you need is the lines that assign value to A and the last two lines to select a file and then write to the file. You don't need the for-loop anymore. That's probably why two files are created.
카테고리
도움말 센터 및 File Exchange에서 Desktop에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!