- 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!