I have a dataset from a fitbit that gives e.g. steps per minute. The steps are data I can create an array from but the timedata is between semicolons which seems to give problems. Below is a picture of how the data is presented. And here is the code I used to retrieve it:
str = fileread('12h.json'); % dedicated for reading files as text 
data = jsondecode(str); % Using the jsondecode function to parse JSON from string to a Matlab struct.
step_data = data(1).data.data.activities_steps_intraday;
step_data = struct2cell(step_data);
time = cell2mat(step_data(1,:));
step = cell2mat(step_data(2,:));
How do I create an array for time from this data?
Here is how the data is converted at this moment:

 採用された回答

Matt J
Matt J 2023 年 1 月 18 日
編集済み: Matt J 2023 年 1 月 18 日

0 投票

str = fileread('12h.json'); % dedicated for reading files as text 
data = jsondecode(str); % Using the jsondecode function to parse JSON from string to a Matlab struct.
step_data = data(1).data.data.activities_steps_intraday;
step_data = struct2cell(step_data);
time=datetime(step_data(1,:),'Format','HH:mm:ss')

2 件のコメント

Anton
Anton 2023 年 1 月 18 日
That is a really easy fix. Thank you!
Anton
Anton 2023 年 1 月 18 日
One extra question: Is there a way to add the date to these timestamps? Because there is no defined date in the timestamps, so it automatically displays the date of today.

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

その他の回答 (0 件)

製品

リリース

R2022b

タグ

質問済み:

2023 年 1 月 18 日

コメント済み:

2023 年 1 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by