I have this code:
name = strrep(name,' ','_');
date = strrep(date,' ','_');
FileName=[name '_' date '.txt'];
file=fopen(FileName,'wt');
it creates a text file with the name and date I get from some edittext box in GUI in the current folder.
Can I add a directory path to that so it creates the text file in another folder like: ../DB/filename.txt ?

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 7일

0 개 추천

file=fopen(fullfile(pwd,FileName),'wt')

댓글 수: 2

Graur Alin
Graur Alin 2015년 7월 7일
Ok, it does the same thing. Let me explain again what I really need. This function creates the text file in the current work folder, let's say /Work/name_date.txt. I need it to create the text file in another folder inside the Work folder, like /Work/DB/name_date.txt.
f=fullfile([pwd '\DB'],'name_date.txt')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

질문:

2015년 7월 7일

댓글:

2015년 7월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by