필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
please suggest something. i am new to matlab

채택된 답변

Akbar
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
  댓글 수: 3
Akbar
Akbar 2018년 6월 5일
편집: Akbar 2018년 6월 5일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by