- 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 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
BhaTTa
il 21 Nov 2024 alle 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 Commenti
Vedere anche
Categorie
Scopri di più su Time Series in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!