- Prepare the Data: Ensure your array contains two rows, with the first row representing time intervals and the second row representing digital data values.
- Accumulate Time: Convert the time intervals into cumulative time points.
- Create a Time Series: Use the timeseries function to create a time series object.
- Use in Simulink: Pass the timeseries object to Simulink using a From Workspace block.
convert an array to time series and input to simulink
3 次查看(过去 30 天)
显示 更早的评论
HI all
A matlab simulink file is runing, an input is given to the m file, processes are done inside the m file, an array (double) with a row of time and a row of digital data is created.
each time cell indicates for how many second the corresponding digital data is valid.
for instance:
time Digital data
1 0
4 1
2 1
3 0
I need to turn this array back to my simulink and use it. the problem is that I need it as time series. each calculated value should be send out consecutively for the use of other parts of simulink file.
any idea?
I have checked time series help, but could not address the problem.
tnx
0 个评论
回答(1 个)
BhaTTa
2024-11-21,5:02
Hey @Mohammad Ali Khademi, I assuume that you want to convert your array of time and digital data into a time series format suitable for Simulink, for that you can use MATLAB's timeseries object as per the below given way:
Below I have attached the sample code:
% Example data
timeIntervals = [1, 4, 2, 3]; % Time intervals
digitalData = [0, 1, 1, 0]; % Digital data values
% Calculate cumulative time points
cumulativeTime = cumsum(timeIntervals);
% Create a timeseries object
ts = timeseries(digitalData, cumulativeTime);
% Display the timeseries
disp(ts);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time Series 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!