creating a look up table to compare datetime stamps

4 ビュー (過去 30 日間)
Dharmesh Joshi
Dharmesh Joshi 2022 年 11 月 20 日
コメント済み: Dharmesh Joshi 2022 年 11 月 24 日
Hi
I need to create a look up table, where i would need to specify. This will need to a manual table, where i would need to spicify the following:
Start DateTimeStamp, Stop DateTimeStamp and Device ID.
Then i would like to compare a incoming datastreams timestamp, aganist this lookup table to to NaN samples between the dates.
How can i create a table from Matlab, instead of using spreadsheet and how do you compare timestamps?

採用された回答

Star Strider
Star Strider 2022 年 11 月 20 日
Start with the isbetween function, and add a separate logical vector for the device ID —
DateTime = datetime('now')+hours(0:4:150).';
DeviceID = randi(9, size(DateTime));
T1 = table(DateTime,DeviceID)
T1 = 38×2 table
DateTime DeviceID ____________________ ________ 20-Nov-2022 16:09:11 6 20-Nov-2022 20:09:11 3 21-Nov-2022 00:09:11 4 21-Nov-2022 04:09:11 8 21-Nov-2022 08:09:11 1 21-Nov-2022 12:09:11 4 21-Nov-2022 16:09:11 2 21-Nov-2022 20:09:11 8 22-Nov-2022 00:09:11 7 22-Nov-2022 04:09:11 7 22-Nov-2022 08:09:11 4 22-Nov-2022 12:09:11 5 22-Nov-2022 16:09:11 5 22-Nov-2022 20:09:11 5 23-Nov-2022 00:09:11 4 23-Nov-2022 04:09:11 8
Start_DateTimeStamp = "21-Nov-2022 12:00";
Stop_DateTimeStamp = "22-Nov-2022 18:00";
Device_ID = randi(9)
Device_ID = 7
Lv = isbetween(T1.DateTime, Start_DateTimeStamp, Stop_DateTimeStamp) & Device_ID==T1.DeviceID;
Query = nnz(Lv)
Query = 2
Result = T1(Lv,:)
Result = 2×2 table
DateTime DeviceID ____________________ ________ 22-Nov-2022 00:09:11 7 22-Nov-2022 04:09:11 7
Make appropriate changes to work with your data.
.
  10 件のコメント
dpb
dpb 2022 年 11 月 23 日
Nothing prevents you from organizing the file structure however it best suits the task...
Again, you've given us absolutely no context with which to work; how are we to have any idea of any specific organization or code structure that would fit?
Dharmesh Joshi
Dharmesh Joshi 2022 年 11 月 24 日
Well i have sensors, such as tempeture,Humdity, motion etc , that are reporting data to our cloud servers as JSON. Then using API i am downloading that data onto Matlab.
But these sensors if they are placed away from the site, will produce false results, so the aim is to specify the timestamps and make the data NaN to avoid any confussion.

サインインしてコメントする。

その他の回答 (1 件)

dpb
dpb 2022 年 11 月 20 日
Read all about <MATLAB timetable> here. It has all the tools ready-built for you...

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by