- 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
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
BhaTTa
am 21 Nov. 2024 um 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 Kommentare
Siehe auch
Kategorien
Mehr zu Time Series finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!