MATLAB: Averaging each .STD files

MATLABmoses

Greetings. I have been pondering and working hard on this issue since I came here to ask for solutions. I have over 100 .std files in which each of them has 10 headers and each header has 24 hours data of which each hour has 60 values. I want to loop through the hundred data files and get the average of the 24hrs data with graphs. I was only able to do for each data at a time and it's very tedious.

Best Answer

[Update: Based on comments from Moses, I submitted another answer to this question. See below.]
Try this:
files = dir("*.Std");
N = numel(files);
Filename = strings(N,1);
Date = NaT(N,1);
Mean1 = zeros(N,1);
Mean2 = zeros(N,1);
Mean3 = zeros(N,1);
Mean4 = zeros(N,1);
for k = 1:numel(files)
name = string(files(k).name);
A = readmatrix(name,"FileType","text");
[~,base_name,~] = fileparts(name);
base_name_parts = split(base_name,"-");
Filename(k) = name;
Date(k) = datetime(join(base_name_parts(2:4),"-"));
means = mean(A,1);
Mean1(k) = means(1);
Mean2(k) = means(2);
Mean3(k) = means(3);
Mean4(k) = means(4);
end
T = timetable(Date,Filename,Mean1,Mean2,Mean3,Mean4);
When I run this with your data files, T is this:
8×5 timetable
Date Filename Mean1 Mean2 Mean3 Mean4
___________ ________________________ ______ ______ ______ _____
01-Jan-2015 "bjco001-2015-01-01.Std" 11.992 24.82 2.6294 6.38
02-Jan-2015 "bjco002-2015-01-02.Std" 11.992 22.25 2.1003 6.38
03-Jan-2015 "bjco003-2015-01-03.Std" 11.992 25.834 1.9662 6.38
04-Jan-2015 "bjco004-2015-01-04.Std" 11.992 32.088 1.6014 6.38
05-Jan-2015 "bjco005-2015-01-05.Std" 11.992 25.03 1.8935 6.38
06-Jan-2015 "bjco006-2015-01-06.Std" 11.992 31.423 1.5822 6.38
07-Jan-2015 "bjco007-2015-01-07.Std" 11.992 31.528 1.8784 6.38
08-Jan-2015 "bjco008-2015-01-08.Std" 11.992 31.08 1.6912 6.38
...
Plot sample:
plot(T.Date,T.Mean2)