How to plot data from different folders

8 visualizaciones (últimos 30 días)
iseng
iseng el 20 de Mzo. de 2018
Editada: Benjamin Großmann el 22 de Mayo de 2018
Hi, I want to plot the same named data from different subfolders. The first level of folder is GM and in total 20 of them exists. Then 10 subfolders exist named #pga in each GM folder. I tried to modify and make the following code work but couldnt manage. Can anyone help?
(for g=1:2 for k=1:9
eval(['load num2str(g),gm\',num2str(k/10),'pga\pga',num2str(k/10),'drift.out'])
end
for m=1:9 eval(['maxdrift(m,1)=max(pga0_',num2str(m),'drift(:,2));']); end maxdrift(10,1)=max(pga1_0drift(:,2)); end)

Respuesta aceptada

Benjamin Großmann
Benjamin Großmann el 23 de Abr. de 2018
Editada: Benjamin Großmann el 22 de Mayo de 2018
You can get the file information (name, folder, date, ...) of files within subfolders using the dir command and wildcards. e.g. if your are in the folder which contains the #gm folders then the command
files = dir('./*/*/*.out');
will return a struct of all *.out files within all the second level subfolders. You can then easily build a cell arrray of filenames and operate on them using cellfun:
filePaths = fullfile({files(:).folder},{files(:).name});
cellfun(@(x) disp(x),filePaths,'UniformOutput',false); % substitute disp by your function and add a return value to have catch your functions output in a cell

Más respuestas (0)

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by