Reputation: 5789
I start with Matlab and would like to know how could I access to a folder and get contents to access files and read them. I have a variable in workspace tmpfolder that is equal to 'path to folder' but I don't find how could I make dir(tmpfolder) and get files, browse any file content to get a string value...
Upvotes: 0
Views: 2054
Reputation: 182
If you have an image file in jpeg format in another folder named myimage
and a text file called mytext
, use:
prefix_image='myimage';
prefix_data='mytext';
fileformat='.jpg';
dataformat='.txt';
folder='C:\Users\khaled\Documents\MATLAB\';
image = imread(strcat(folder,prefix_image,fileformat));
data=textread(strcat(folder,prefix_data,fileformat),'%f');
Upvotes: 1
Reputation: 272467
I would start with dir()
and fopen()
.
More generally, try starting at the beginning: Working with Files and Folders.
Upvotes: 2