Assigning Columns to a table without using loops - and perform i.e. diff on a column
显示 更早的评论
Hello, I have an events log that I want to be able to pull out relevant times and types of triggers into an array of some sort. As its a mixture of text and numbers I originally thought of using a cell array, but have since preferred the idea of using a table.
Ultimately I want a table showing
[count, FrameNumber, (AbsTime-AbsTime_from_1st event) trigger type
All of this info is available in the events.Data and events.type fields
This was my basic attempt to get going
Type=events(:).Type
AbsTime=datetime(events(:).Data.AbsTime)
T0=datetime(events(1).Data.AbsTime)
D=diff(T0)
table(Type,AbsTime,T0,D)
But I see an error
Intermediate dot '.' indexing produced a comma-separated list with 5 values, but it must produce a single value when followed by subsequent indexing
operations.
Error in HTS_TestSoftware/StopVidButtonPushed (line 8572)
AbsTime=datetime(events(:).Data.AbsTime)
Does this mean I have to use loops then?
Also how do I include the diff of the abs time to get each individual time difference?
events =
1×5 struct array with fields:
Type
Data
ans =
struct with fields:
% Here is events.Data-----------------------------------------------
AbsTime: [2025 2 14 15 22 54.8366]
FrameNumber: 0
RelativeFrame: 0
TriggerIndex: 0
ans =
struct with fields:
AbsTime: [2025 2 14 15 22 55.0519]
FrameNumber: 0
RelativeFrame: 0
TriggerIndex: 0
ans =
struct with fields:
AbsTime: [2025 2 14 15 22 55.1534]
FrameNumber: 1
RelativeFrame: 0
TriggerIndex: 1
ans =
struct with fields:
AbsTime: [2025 2 14 15 22 55.2520]
FrameNumber: 2
RelativeFrame: 0
TriggerIndex: 2
ans =
struct with fields:
AbsTime: [2025 2 14 15 22 55.4438]
FrameNumber: 3
RelativeFrame: 1
TriggerIndex: 3
% Here is events.Type-----------------------------------------------
ans =
'Start'
ans =
'Trigger'
ans =
'Trigger'
ans =
'Trigger'
ans =
'Stop'
Type =
'Start'
2 个评论
Cris LaPierre
2025-2-14
Please attach your data file and the code you are using to import it.
It is hard to provide a solution specific to your use case without having your data.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
