Different computer save folder
Afficher commentaires plus anciens
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 commentaires
OCDER
le 13 Oct 2017
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
le 13 Oct 2017
OCDER
le 13 Oct 2017
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
le 13 Oct 2017
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
le 13 Oct 2017
Réponse acceptée
Plus de réponses (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);
1 commentaire
Debbie Oomen
le 1 Nov 2017
Catégories
En savoir plus sur Text Data Preparation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!