- Looping through struct elements for each timestamp
- Keeping track of all timestamps
- Looping through each particular cell array and storing its measurements
- Creating a timeseries object using stored timestamps and measurements
Struct with cell array to timeseries for Simulink implementation
10 次查看(过去 30 天)
显示 更早的评论
From the Driving Scenario Designer (Automated Driving Toolbox) I have gathered some radar measurements in the form a struct with the fields Time and ObjectDetections. The ObjectDetections contain a variable number of cells witht the object data. This looks as shown below.
I created this data using Matlab 2021, but for some specific reasons I need to use this data as input in a 2017b Simulink model, but I'm only interested in the measurement data in RadarData_L(:),ObjectDetections(:,1). I tried to convert it to a timeseries object, but then the error 'The first argument must contain the data.' pops up. Should I use timeseries or is there another alternative?

0 个评论
回答(1 个)
Rushil
2025-3-28
Hello
I believe that you are using the "drivingScenarioDesigner" function alongside the “drivingRadarDataGenerator” sensor in order to access sensed radar signals for further processing as timeseries data.
The data from RadarData_L can be accessed and converted into timeseries using the following sequence of steps:
Below is some implementation that may guide you:
len = length(RadarData_L);
times = zeros(len,1);
meas = {}; % cell array to store measurements
for i = 1:len
times(i) = RadarData_L(i).Time;
obj_dec = RadarData_L(i).ObjectDetections;
cur_meas = [];
for j = 1:length(obj_dec)
det = obj_dec{j};
data = det.Measurement;
cur_meas = [cur_meas; data(:)']; % append to prev measurements
end
meas{i} = cur_meas;
end
% convert this cell array to a matrix
result = cell2mat(meas);
ans = timeseries(result, times);
Below is the link for “timeseries” that is used above:
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!