Machine precision in simulink

Technical Source
2 min readSep 9, 2021

--

I am currently working on simulink model.

One of the equations is

"L = qf*(XL0+(XL1*alpha_quadrant))"

where “alpha_quadrant” is constantly zero. “XL0” and “qf” are both constants. The result of the equation, when graphed, should be constantly -11.08, but as it can be seen in the picture the result keeps fluttering.

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

To determine what is happening, a good approach is to log the key signals involved.

Then use MATLAB to investigate the logged values.

I suspect you’ll find that either alpha_quadrant isn’t always zero or qf is not constant or XL0 is not constant.

The differences in values from what you expect might be very small so you could use some techniques like the following.

format long g  % will shows higher precision than short, but can still hide some differencesa = 0.05;
b = a + eps(a);
c = a + 2*eps(a);
v = [c,a,b] % the differences will not be visible in the command window
% converting to a string with 17 digits will be enough to see differences
mat2str(v,17)
% subtracting values is another way to make the differences visible in the
% command window
dv = diff(v)
max(dv)
min(dv)

The output of this code is:

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet