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 次查看(过去 30 天)
显示 更早的评论
please suggest something. i am new to matlab
0 个评论
采纳的回答
Akbar
2018-6-4
编辑:Akbar
2018-6-4
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
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!