Effacer les filtres
Effacer les filtres

I have a text file having 7 columns. First column is UTC time in hours. This file is having data for almost 1 month. i need to separate data day wise and save it to different day . whenever first column value is > than 0.00, a new day is starting

1 vue (au cours des 30 derniers jours)
please suggest something. i am new to matlab

Réponse acceptée

Akbar
Akbar le 4 Juin 2018
Modifié(e) : Akbar le 4 Juin 2018
First I have imported your data to matlab using its 'import data' tool. And created a table called 'anci'. Whose size is 5003x7. Where VarName1 is the first column. This code creates a cell Array for each new day. I got a cell Array called 'days' which is of size 37. So, your dataset contains 37 days. When you click on any cell you can see data collected for that particular day. I noticed that most of the days contain about 133 records. Please accept my answer.
%if the difference between previous row and next is
%more than 22, then record the index because thats where a
%new day starts.
k=1;
for i = 2:height(anci)
if abs(anci.VarName1(i) - anci.VarName1(i-1))>22
ind(k) = i;
k=k+1;
end
end
days = cell(length(ind),1); %preallocates dimensions
days{1,:} = anci(1:ind(1)-1,:); % first day
for i = 2:length(ind) % starting from second day
%creates cell array that contains tables; each cell beginning with
%index ind(i) of table anci, ending on index ind(i+1)-1
if i ~= length(ind) %if not last pass
days{i,:} = anci(ind(i):ind(i+1)-1,:);
else
days{i,:} = anci(ind(i):end,:);
end
end
  3 commentaires
Akbar
Akbar le 5 Juin 2018
Modifié(e) : Akbar le 5 Juin 2018
Because the ind vector doesn't contain the very first row index 1, so i included it manually. And wrote like this: 1:ind(1)-1
days{1,:} = anci(1:ind(1)-1,:); % first day

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by