extract specific file from list of folders
Show older comments
I have 2 folders called EXP1, and EXP2, and within each of those folders is 4 folders, labelled 1-4. I have a code which adds each path to matlab, which may help visualize this:
clear
%add complete paths to every template file you will be using
addpath('C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT1\1',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT1\2',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT1\3',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT1\4',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT2\1',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT2\2',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT2\3',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT2\4');
Each of the text files is named EXP(n)_SQ(m)_Template, with the EXP folder number replacing n, and the subfolder replacing m.
I want a user to be able to input a specific number for an experiment, and squad, and have that file used for the remainder of the script.
Here is what I have:
clear
%add complete paths to every template file you will be using
addpath('C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT1\1',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT1\2',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT1\3',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT1\4',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT2\1',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT2\2',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT2\3',...
'C:\Users\Administrator\Dropbox (*******)\******* Team Folder\Matlab\RFID chip reader\EXPT2\4');
user_input_exp = input('Enter Experiment Number: ', 's');
user_input_squad = input('Enter Squad Number: ', 's');
Mac_Templ = importdata('EXP(user_input_exp)_SQ(user_input_squad)_Template.txt');
I get this error:
Error using importdata (line 139)
Unable to open file.
Error in test_editing (line 17)
Mac_Templ = importdata('EXP(user_input_exp)_SQ(user_input_squad)_Template.txt');
If I take away the '' surrounding the file name, I get this error by the underscores:
Error: File: test_editing.m Line: 17 Column: 43
Invalid text character. Check for unsupported symbol, invisible character, or pasting of
non-ASCII characters.
Any help is appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!