Help with a For Loop?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
John Evans
el 27 de Abr. de 2018
Respondida: John Evans
el 8 de Mayo de 2018
I am pretty new to matlab (am a beginner) and is completely lost; hopefully someone can help me here.
I am currently working on an excel data set with 151 columns of data (I have attached a sample file). The first column has both the time and date on which the data points were collected (at 15min intervals for 8 weeks). Can someone help me with writing a code (eg a for loop) where data from only 12midnight to 6am for the weeks for each data set (column) is collected and then finds the average of it.
My sincere thanks for whoever can help.
0 comentarios
Respuesta aceptada
Walter Roberson
el 27 de Abr. de 2018
t = readtable('Book1.xls');
h = hour(t.Time);
m = minute(t.Time);
mask = h <= 5 | (h == 6 & m == 0); %hour 6 is only valid for 06:00 exactly
selected_data = t(mask,:);
means = nanmean(selected_data{:,2:end});
It was not really clear what interval the means were to be taken over.
You need the nanmean because there are nan in some of the columns.
12 comentarios
Walter Roberson
el 7 de Mayo de 2018
Ah, looks like groupsummary() was added in R2018a. I will have a look a bit later to see what I can replace it with that will run in your version.
Más respuestas (1)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!