Files won't consistently save in current working directory
    조회 수: 7 (최근 30일)
  
       이전 댓글 표시
    
I am running Matlab R 2012b on Microsoft Windows XP Professional.
I frequently save data or figures to file while running analyses. Previously, if I did not specify a full pathname for the file, it would save in my current directory.
Since I upgraded to 2012b, I find that frequently my files aren't where I expect them to be. There seems to be no consistent pattern to the directory in which they end up, either.
For example, take directory A. A has children B1 and B2. B1 has children C1 and C2. B2 has children C3 and C4. B2 and its children are in the Matlab path, the others are not.
Say I am running a script in directory C1. Files generated in that script have ended up in its sibling C2, its parent B1, it's grandparent A, it's uncle B2, and even it's cousins C3 and C4. Recently, I ran a loop 8 times. Six of the files ended up in a sibling directory. The last two ended up in the current working directory.
To avoid playing hide-and-seek with my files, I am going to always use full path names. However, I am concerned this might be a symptom of a larger problem. If so, is it likely to be with Windows or Matlab?
댓글 수: 0
답변 (1개)
  Jan
      
      
 2013년 2월 8일
        I'm convinced, that Matlab saves the files in the current directory. When the files appear at unexpected locations, there are some cd() commands hidden in your code. Neither Matlab 2012b nor Windows XP change the current folder magically.
Usual locations for unexpected changes of the current directory are callbacks of timer() or GUI elements.
However, using absolute path names is the right way.
댓글 수: 2
  the cyclist
      
      
 2013년 2월 8일
				Consistent with Jan's answer, I have never had this behavior where I could not trace it to an unexpected cd(). (I've never seen it happen just using tic and toc.)
I wonder if you could boil this down to the simplest possible script that you can get to replicate the behavior, and then post that. (It may also help you debug it, by reducing it to the bare bones.)
참고 항목
카테고리
				Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


