Effacer les filtres
Effacer les filtres

what changes can I make so that all files are selected automatically

4 vues (au cours des 30 derniers jours)
Manav Divekar
Manav Divekar le 18 Oct 2021
Commenté : Cris LaPierre le 18 Oct 2021
[files,path] = uigetfile({'.txt'},'MultiSelect', 'on');
if iscell(files)
for n = 1:length(files)
data = importdata(fullfile(path,files{n})); % fullfile including path
% save data
end
else
data = importdata(fullfile(path,files));
% save data
end

Réponses (1)

Cris LaPierre
Cris LaPierre le 18 Oct 2021
uigetfile does not have an option that automatically selects all files. Consider using uigetdir instead of uigetfile. You can then use dir to get every file in that folder. You can also use a wild card to extract just files that match a pattern.
  2 commentaires
Manav Divekar
Manav Divekar le 18 Oct 2021
Can you tell how write dir instead uigetfile using this logic.
Cris LaPierre
Cris LaPierre le 18 Oct 2021
You can find a good example for loading all *.xlsx files in a folder here.
You would use uigetdir to get the path to the folder. If you do not need the path to be dynamic, you can hardcode it without using uigetdir.
Make an attempt and, if you can't get it working, share the code you wrote along with any error messages you are getting (all the red text).

Connectez-vous pour commenter.

Catégories

En savoir plus sur Low-Level File I/O dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by