How to plot the results below ?
Afficher commentaires plus anciens
Hi,
Please see the code below I used to extract the information from the folder. So the folder has 28 sub-folder with the name "Run 12-27-56.Adaptive PIV.6uqqm6yu", and so on. I want to plot on X-axis number of floder like 1,2,,3,4,5,6....28 and on y-axis corresponding file name (only the number part for example 12-27-56) which is a timestamp actually. Can you help, I am posting the code and result below.
Code:
close all; clear all; clc
%Location of the directory
Location = 'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_A\Data_Vector_Masked';
% Get a list of all files and folders in this folder.
files = dir(Location);
% Get a logical vector that tells which is a directory.
dirFlags = [files.isdir];
% Extract only those that are directories.
subFolders = files(dirFlags); % A structure with extra info.
% Get only the folder names into a cell array.
subFolderNames = {subFolders(3:end).name} % Start at 3 to skip . and ..
%Print folder names to command window.
for k = 1 : length(subFolderNames)
fprintf('Sub folder #%d = %s\n', k, subFolderNames{k});
end
Results:
Sub folder #1 = Run 12-27-56.Adaptive PIV.6uqqm6yu
Sub folder #2 = Run 12-28-48.Adaptive PIV.6uqqlrqv
Sub folder #3 = Run 12-29-46.Adaptive PIV.6uqqlgku
Sub folder #4 = Run 12-30-23.Adaptive PIV.6uqql4fz
Sub folder #5 = Run 12-31-15.Adaptive PIV.6uqqkre7
Sub folder #6 = Run 12-31-50.Adaptive PIV.6uqqkfgv
Sub folder #7 = Run 12-32-25.Adaptive PIV.6uqqk3d3
Sub folder #8 = Run 12-33-17.Adaptive PIV.6uqqjqh2
Sub folder #9 = Run 12-33-54.Adaptive PIV.6uqqjctq
Sub folder #10 = Run 12-34-27.Adaptive PIV.6uqqiyst
Sub folder #11 = Run 12-35-04.Adaptive PIV.6uqqip1p
Sub folder #12 = Run 12-36-17.Adaptive PIV.6uqqidrr
Sub folder #13 = Run 12-36-47.Adaptive PIV.6uqqi25r
Sub folder #14 = Run 12-37-21.Adaptive PIV.6uqqhnwu
Sub folder #15 = Run 12-37-58.Adaptive PIV.6uqqhcsl
Sub folder #16 = Run 12-38-37.Adaptive PIV.6uqqh0on
Sub folder #17 = Run 12-39-27.Adaptive PIV.6uqqgp8m
Sub folder #18 = Run 12-40-01.Adaptive PIV.6uqqgdqt
Sub folder #19 = Run 12-40-36.Adaptive PIV.6uqqg1kn
Sub folder #20 = Run 12-41-11.Adaptive PIV.6uqqfpie
Sub folder #21 = Run 12-42-03.Adaptive PIV.6uqqfco7
Sub folder #22 = Run 12-43-07.Adaptive PIV.6uqqf0sv
Sub folder #23 = Run 12-43-59.Adaptive PIV.6uqqenyl
Sub folder #24 = Run 12-44-36.Adaptive PIV.6uqqdwdb
Sub folder #25 = Run 12-45-16.Adaptive PIV.6uqqdkcu
Sub folder #26 = Run 12-45-51.Adaptive PIV.6uqqd6wt
Réponse acceptée
Plus de réponses (1)
Voss
le 14 Jan 2022
Here is something you can try:
close all; clear all; clc
%Location of the directory
Location = 'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_A\Data_Vector_Masked';
% Get a list of all files and folders in this folder.
files = dir(Location);
% Get a logical vector that tells which is a directory.
dirFlags = [files.isdir];
% Extract only those that are directories.
subFolders = files(dirFlags); % A structure with extra info.
% Get only the folder names into a cell array.
subFolderNames = {subFolders(3:end).name} % Start at 3 to skip . and ..
timeStamps = regexp(subFolderNames,'(\d+)-(\d+)-(\d+)','tokens');
timeStamps = vertcat(timeStamps{:});
timeStamps = cellfun(@str2double,vertcat(timeStamps{:}));
date_of_year = [2022 1 14];
y = datetime( ...
date_of_year(1),date_of_year(2),date_of_year(3), ...
timeStamps(:,1),timeStamps(:,2),timeStamps(:,3));
plot(1:numel(subFolderNames),y);
2 commentaires
muhammad choudhry
le 14 Jan 2022
Catégories
En savoir plus sur File Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
