how to read the .c file contents from the browsed files by matlab code..?

9 vues (au cours des 30 derniers jours)
Thamilarasi T
Thamilarasi T le 17 Mai 2014
Réponse apportée : dpb le 17 Mai 2014
I am supposed to write a program choose the folder and read the file contents.Inside the folder i will have different types of files.in that i want to read only the files which is having the end name as "_data.c" .
folder_name = uigetdir('','source_code')
folder_name =
C:\Users\tamil\Desktop\Source_code
i have selected the folder with matlab code.but how do i read the file..?

Réponses (1)

dpb
dpb le 17 Mai 2014
folder_name = uigetdir('','source_code');
c=dir(fullfile(folder_name,'*_data.c')); % return directory list of matching files
for i=1:length(c)
d=importdata(c(i).name);
% do what you need w/ the resulting cell array here
...
end

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by