I have a large data set that contains multiple tests for the same pieces of equipment over many years. How can I isolate the latest test results only for the various pieces of equipment? There is a date stamp and equipment id and test results.
For example, for motor X, what are the last or current oil reports and ignore previous old test.

댓글 수: 2

KL
KL 2017년 11월 22일
how do you store your data?
Faustino Quintanilla
Faustino Quintanilla 2017년 11월 22일
I have the information in a table. The table is updated daily with new test information.

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

 채택된 답변

KL
KL 2017년 11월 22일

0 개 추천

use sortrows,
sortedTable = sortrows(yourTable,'timestampColumnName')

댓글 수: 6

Faustino Quintanilla
Faustino Quintanilla 2017년 11월 22일
I was able to sorted them, but how do I isolate the last test for various equipment...
  • Position_id Test Result Test Date
  • -9999989 1 '2016-12-15 00:00:00.0000000'
  • -9999989 1 '2014-12-08 00:00:00.0000000'
  • -9999987 1 '2017-04-04 00:00:00.0000000'
  • -9999987 1 '2016-11-16 00:00:00.0000000'Just need the last entry of 2016 or 2017 for the porsition_id.
KL
KL 2017년 11월 22일
T1 = sortrows(T(T.Position_id==x,:),'Time');
then T1(end) should have the latest value for the position_id x
Faustino Quintanilla
Faustino Quintanilla 2017년 11월 27일
I tried the T1= sortrows(T(T.Position_id==x,:),'Time');... However, I t does not return the last entry.... DO I need to include a @max to single out? (not sure)
KL
KL 2017년 11월 27일
The latest entry should be the last row of T1.
T1(end,:)
Here is the code used. Where do I add the T1(end,:)?
for x=1:height(sortedTable)
T1 = sortrows(sortedTable(sortedTable.position_id==x,:),'sampledt_MAIN');
end
KL
KL 2017년 11월 27일
Alright, you're extracting it for all equipments, so
T_latest = table;
for x=1:height(sortedTable)
T1 = sortrows(sortedTable(sortedTable.position_id==x,:),'sampledt_MAIN');
T_latest = [T_latest; T1(end,:)];
end
now, T_latest should have the last entries corresponding to all x.

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

추가 답변 (1개)

Faustino Quintanilla
Faustino Quintanilla 2017년 11월 27일

0 개 추천

I get an error... "Subscript indices must either be real positive integers or logicals." The intent is remove duplicate rows that have a older date stamp.. How to I correct the error?

카테고리

도움말 센터File Exchange에서 Language Fundamentals에 대해 자세히 알아보기

질문:

2017년 11월 22일

답변:

2017년 11월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by