Different computer save folder
이전 댓글 표시
I have a script that I need to share with my professor. I used the commands uigetfile and uigetdir so that my professor can select my sent files for analysing but I was wondering if there was an easier way that my professor could use the scripts and if there is a way that he can write everything to a folder? I have already seen something like this : [pathname ] but I can not figure it out. Please help
댓글 수: 6
OCDER
2017년 10월 13일
There may be a solution depending on what your requirements are:
- Can you list in order the current steps taken by your professor? Ex: 1) download script, 2) copy file, 3) open matlab, 4) find + run script, 5) select file, 6) save file, 7) move file....
- What file is this script accessing? (Or show us the script)
- What is the script generating?
- Do you want the script to access many different files with different names and different folder locations? uigetfile is pretty convenient, and you can set the default dir it opens to.
- Do you have a shared folder setup on a network that's always there?
- What is "everything" that needs to be written to a folder?
Debbie Oomen
2017년 10월 13일
OCDER
2017년 10월 13일
Is the script located in HIS computer in the right folder? If so, the following can be used to determine the directory of the script:
TargetDir = fileparts(mfilename('fullpath'))
Also, how do you want to save T, f, N? as a txt, mat, csv, xlsx? What about t, y1, which are different sizes than f, fs, T, etc.?
Debbie Oomen
2017년 10월 13일
I see, so you want to save the output folder to the parent directory of the script? EX:
Professor computer has:
C:/ThisDir/Script
C:/ThisDir/EMG
You want script to automatically find the EMG files, and then save results to:
C:/ThisDir/output.xlsx ? or
C:/ThisDir/Ouput/output.xlsx ?
Also, I'm assuming output.xlsx is saving T, f, fs, etc for every .emg file (so 100 emg files will give you 100 data rows) ?
Debbie Oomen
2017년 10월 13일
채택된 답변
추가 답변 (1개)
A simple way to do this is to use mfilename to find the path to where the file is being run on the professor's computer.
[folderPath,fileName] = fileparts(mfilename('fullpath'));
OutputPath = fullfile(folderPath,'OutputDirectory');
if ~exist(OutputPath,'dir')
mkdir(OutputPath)
end
outputFile1 = fopen(fullfile(OutputPath,'OutputFile1.txt'),'w');
fclose(outputFile1);
카테고리
도움말 센터 및 File Exchange에서 Text Data Preparation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!