Sample Time from To Workspace not precise
Show older comments
I'm having trouble with the sample time when passing data from Simulink to the Workspace using the To Workspace block.
I have an electrical circuit (with PLECS blockset) and I'm measuring a voltage in a certain point. The measure this voltage I defined a sample time of Ts=1/(50*256)=7.8125e-5 using a ZOH block (The election of this sample time is from a real life voltmeter). The simulation is set for continouos time, so the output of the ZOH is a continouos stepped signal with steps every Ts seconds. The result of the simulation is shown below with a time span of 5*Ts.

This signal is passed to a To Workspace block with the sample time set to Ts, but the arrays I'm getting in the workspace aren't entirely correct.
Also:
Limit data points to last = inf
Decimation = 1
Log fixed-point data as a fi object is checked
If I use the Cursor Measurments of the Simulink scope, the values in each step are:
[0.000, 0.257, 0.983, 2.224, 3.720]
But when I print this array from the workspace I get:
[0.000, 0.257, 0.983, 0.983, 3.7204]
In the bolded data point, the simulation time should be, 3*Ts = 2.34375e-4 [s] and the value should be 2.224. I believe that for some reason, the time it is evaluating is 2.3437e-4 [s] < 2.34375e-4 [s] getting the previous value of 0.983.
Is this because the time values are fixed point decimals? Or because in the continouos time array the point 2.34375e-4 [s] doesn't exist?
Thanks in advance!
Accepted Answer
More Answers (0)
Categories
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!