This seemingly simple question is actually quite complex.
The input data is non-periodic. To hit every value-changing data point, the simulation step size needs to be the largest common factor of 0.7, 1.14 and 2, which is 0.02. So set the simulation to be fixed step size, discrete solver and step size to be 0.02.
To capture every value-changing data point and nothing more, it needs to use a "Detect Change" block to detect the input change and then enable the "To Workspace" data capture only at that moment.
The "interpolate data" option of the "From Workspace" block needs to be un-checked. The "Form output after final data value by" needs to be set as "holding final value".
Attached is the example model in R2019b.
>> out.simout.Time
ans =
0
0.7000
1.1400
2.0000
>> out.simout.Data
ans =
4
8
10
7
4 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/713398-variable-sample-time-with-different-time-values#comment_1256743
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/713398-variable-sample-time-with-different-time-values#comment_1256743
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/713398-variable-sample-time-with-different-time-values#comment_1257673
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/713398-variable-sample-time-with-different-time-values#comment_1257673
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/713398-variable-sample-time-with-different-time-values#comment_1258433
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/713398-variable-sample-time-with-different-time-values#comment_1258433
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/713398-variable-sample-time-with-different-time-values#comment_1264215
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/713398-variable-sample-time-with-different-time-values#comment_1264215
Sign in to comment.