Split array of sensor data by indexing

3 ビュー (過去 30 日間)
Eric
Eric 2020 年 10 月 20 日
コメント済み: Eric 2020 年 10 月 20 日
Hey all,
Beginner here. Searching for an effective, simple solution to a data prep problem.
I'm building a function to import sensor data (attached). It comes in unsorted, with column "name" as string type (e.g., 'Chest', 'Tib'). This is also mirrored in column "serial", which matches the serial number of that sensor. Other columns timestamp, accx, etc. correspond to one sample measured at that time by each sensor.
I want to automatically detect the unique sensor names (or serial), and then split the array and create a timetable for each sensor. Later, we need to upsample, filter, synchronize, and transform the data of each sensor independently, and I assume that this is simpler when these data are seperated.
I started with this
c=unique(Data.IMU.name)
But am having trouble creating a proper method of indexing or looping for complete this task. Any ideas?
Thanks.
  2 件のコメント
Stephen23
Stephen23 2020 年 10 月 20 日
編集済み: Stephen23 2020 年 10 月 20 日
"I want to ... split the array and create a timetable for each sensor."
Why do you need to do that?
One of the benefits of using tables/timetables is the ability to group data and apply functions those groups:
Whilst it is certainly possible to split up your data into separate tables/timetables (e.g. in a cell array), most likely a much better use of MATLAB would be to just use the table functionality which lets you group and process data within the table. But it really depends on what you are going to do with this data, which so far you have not explained.
Eric
Eric 2020 年 10 月 20 日
I added a line to my query - later, we need to upsample, filter, synchronize, and transform the data of each sensor independently, and I assume that this is simpler when these data are seperated.
I'm reading through that documentation you linked to- working on it, thanks!

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

採用された回答

Stephen23
Stephen23 2020 年 10 月 20 日
編集済み: Stephen23 2020 年 10 月 20 日
S = load('matlab.mat');
T = S.Data.IMU;
G = findgroups(T.name);
C = arrayfun(@(g)T(g==G,:),1:max(G),'uni',0);
You can then trivially loop over the cells of C and do whatever processing you want:
  1 件のコメント
Eric
Eric 2020 年 10 月 20 日
Fantastic, thanks.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by