How to create new file in another folder?

조회 수: 60 (최근 30일)
Naga
Naga 2019년 8월 20일
댓글: Eldhose Poulose 2020년 3월 6일
I have got 2 files namely DCM file and text file.I have to compare the parameters in text file and Dcm file and if those parameters presented, then I have to copy the parameters from DCM file to another new file. I have already written the code in such a way it will do this. But I have create the new file in another folder . How can I do this?
  댓글 수: 3
Naga
Naga 2019년 8월 20일
Thank you. It's creating the new file. But it is not able to read this file when I gave its path to another function. Is there any command for that?
Joel Handy
Joel Handy 2019년 8월 20일
There are lots of commands for that. Can you be more specific when you say the other function can't read the file? Do you get an error? Do you get unexpected results? What code have you tried so far?

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

채택된 답변

Stephen23
Stephen23 2019년 8월 20일
편집: Stephen23 2019년 8월 20일
" But I have create the new file in another folder . How can I do this?"
All MATLAB functions that read/write to data files accept absolute/relative filenames, so you just need to add a relative/absolute path to the filename. You can easily create the complete filename using fullfile.
D = 'C:\somedir\subdir';
N = 'myfile.txt';
fid = fopen(fullfile(D,N),'wt');
...
fclose(fid)
  댓글 수: 1
Eldhose Poulose
Eldhose Poulose 2020년 3월 6일
the fullfile() function is useful when you write several files inside a for loop ,for instance. THANK YOU Stephan

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Name Construction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by