Why do certain sample times in models result in inaccurate results in Simulink 7.1 (R2008a)?

2 views (last 30 days)
When a “From File” or a “From Workspace” block is used at a sample time other than the simulation base sample time, it returns results slightly different from what is expected.
I stored only zeros and ones in a MAT-file. In some cases, the "From File" block returns values in the range of 1e-15 instead of zero.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The "From File" block might not return the exact value stored in the file in some occasions.
This situation can occur when both the following conditions are met:
- The sample time of the "From File" block is not a finite value (for example, 1/3).
- The "From File" is not used at the base sample time of the Simulink model. For example, the Simulink model contains a "From File" block with a sample time of 1/3 and other blocks with a sample time of 0.25.
When both these conditions are met, the sample time of the "From File" block in Simulink might be slightly different from the one specified in the MAT-file. This causes the "From File" block to interpolate between points. When this situation occurs, a stored value of 0 can be transformed into a value in the range of 1e-15.
To work around this issue, a "Rounding Function" block can be inserted after the "From File" block to convert back the 1e-15 value to a 0 value.
See the attached Simulink model for an example of this behavior.

More Answers (0)

Categories

Find more on Interactive Model Editing in Help Center and File Exchange

Products


Release

R2008a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!