How do I access a folder that is inside the current folder while running a function?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Sulaiman Alvi
il 25 Lug 2015
Commentato: Walter Roberson
il 25 Lug 2015
I am writing a function that in different steps needs to access 1 or 2 files in different folders. The function will look something like this:
function Calculation = calc(n)
where n is the name of the file. Each of the folders will have one file named "N" and I want the program to go through each file and get the image data for that file.
2 Commenti
Walter Roberson
il 25 Lug 2015
Is n the name of the folder or the name of the file or the name of the combination?
Risposta accettata
Walter Roberson
il 25 Lug 2015
Presuming that n holds the name of the folder
this_N_name = fullfile(n, 'N'); %N has no extension??
this_data = imread(this_N_name); %imread is not going to be happy with there not being an extension though
6 Commenti
Walter Roberson
il 25 Lug 2015
full_name = fullfile('I0', sprintf('%d.bmp', n));
By the way, when you are working with images, in a number of contexts MATLAB pays attention to whether the array is uint8 or double. When it is uint8 MATLAB expects the values to be in the range 0 to 255; when it is double MATLAB expects the values to be in the range 0 to 1. I recommend you use
A = im2double(imread(f1,'bmp'));
instead of using double()
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Search Path in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!