Effacer les filtres
Effacer les filtres

How to import a specific file

7 vues (au cours des 30 derniers jours)
Shane
Shane le 19 Déc 2012
I know how to import a specific file, but what if matlab has two folders set as pathways to check of which both have same filename and filetype, identical.
example: "example.txt"
and their in both folders, and if you importdata('example.txt');
I assume that will just select one of them depending on whichever it encounters first.
Is there a way to select the file through some function I am unaware of?
Cheers, Shane

Réponse acceptée

Image Analyst
Image Analyst le 19 Déc 2012
Use fullfile() to specify the folder and full file name (path + base file name + extension) of the one you want to import.
fullFileName = fullfile(folder1, 'example.txt');
if exist(fullFileName, 'file')
csvread(fullFileName);
else
message = sprintf('Warning: %s does not exist', fullFileName);
uiwait(warndlg(message));
end

Plus de réponses (0)

Catégories

En savoir plus sur NaNs dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by