Getting an Age from Dataset

I'm trying to get an age from the following data in a matrix array/table, just unsure how to apply the code to my work. If anyone could help it would be amazing!

3 件のコメント

Adam
Adam 2021 年 10 月 19 日
Depends which age you want.
allSamples{ 1, 2:3 }
would give you the first DOB and collection date. Or
[ allSamples.DOB, allSamples.CollectionDate ]
will give you the full column of dates of birth and collection date.
Then it is easy to calculate age from these.
Alana Mera
Alana Mera 2021 年 10 月 20 日
How do i calculate the age?
Star Strider
Star Strider 2021 年 10 月 20 日
One possibility —
DOB = datetime(['06 Jul 1951'; '15 Aug 1943'], 'InputFormat','dd MMM yyyy')
DOB = 2×1 datetime array
06-Jul-1951 15-Aug-1943
CollectionDate = datetime(['01 Mar 2006'; '02 Mar 2006'], 'InputFormat','dd MMM yyyy')
CollectionDate = 2×1 datetime array
01-Mar-2006 02-Mar-2006
Age = caldiff([DOB CollectionDate], {'years' 'months' 'days'}, 2)
Age = 2×1 calendarDuration array
54y 7mo 23d 62y 6mo 15d
.

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

回答 (1 件)

Arunoda shehani
Arunoda shehani 2023 年 5 月 26 日

0 投票

matlab code to determine birthday when enter the NIC number

カテゴリ

ヘルプ センター および File ExchangeTime Series Events についてさらに検索

質問済み:

2021 年 10 月 19 日

回答済み:

2023 年 5 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by