Save as separate file with separate name in txt
조회 수: 2 (최근 30일)
이전 댓글 표시
ds=dataset(‘xlsfile’,’prov.xlsx’);
f1=ds.rem(1:451);
f2=ds.name(1:451);
for i=1:451
if f1(i)==1
%name
c(i)=f2(i);
save('/Users/desktop/c(i)' '.txt','f1')
end
end
I want to have all 1 values in separate file with special name.
댓글 수: 8
Geoff Hayes
2019년 3월 6일
Vania - I don't understand why you are getting a string like '/Users/Desktop/myfolder/0.txt/Users/Desktop/myfolder/102.txt/Users/Desktop/myfolder' which appears to be a concatenation of several attempts to create files. You may need to post more of your code or try moving the sprintf out of the save to get something like
for i=1:451
if f1(i)==1
%name
c(i)=f2(i);
filename = sprintf('/Users/desktop/%d.txt', f2(i));
save(filename,'f1')
end
end
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 String Parsing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!