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!