What is the best way to maintain non-MATLAB files (i.e. *.csv or *.exe) in the MATLAB file hierarchy?

조회 수: 1 (최근 30일)
I'm a fan of placing the file in the appropriate private directory (package or class) to find with 'which' function but am wondering if there is a better way.
  댓글 수: 2
Bob Thompson
Bob Thompson 2018년 12월 19일
What exactly do you mean by 'maintain non-MATLAB files in the MATLAB file hierarchy?' Are these files generalized for use with multiple functions, inputs, or commands, or are they for specific scripts and you are just looking for where to store them?
Image Analyst
Image Analyst 2018년 12월 19일
I just make a folder for each project and store all the files in there or in subfolders of there. If there are some utilities you use in lots of projects, you can make a Utilities folder and store those m-files in there, and then set a path to that folder so your other project files can see/run them. Not sure if that answers your question or not. Maybe you can clarify what you got - how it's arranged/stored - so we can see what you're doing.

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

답변 (1개)

Dan
Dan 2018년 12월 19일
A simple example ... I have a csv file that is used by one and only one class. When it is time to read it from the class method, I exercise csvread('fname.csv') from within the given method of the class and the file will be found because it is in the private directory of the class. The scope of the file is only as big as it needs to be.
A colleague argues that non-MATLAB files do not belong in private directories for classes or packages and he would create another directory in the class (or package) folder and locally reference it given the path to the class constructor found with mfilename.
Just wondering what other think?
(If you are unfamiliar with the special characteristics of the private folder in a class or package, you need to learn about that before you really understand my question.)
  댓글 수: 1
Image Analyst
Image Analyst 2018년 12월 19일
Well, if it's a file used only by that class and no one else, then I'd probably keep it in the folder where the class lives.
Not sure I agree with your colleague. Not that he's wrong, I just believe that's a matter of style.
If you want to keep it in a sub folder of that class called "Data Files" or something like that, then you can.
Either way, I'd use the folder name of the file and use fullfile() to construct the full file name when it comes time to read in that file.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by