matlab accuracy in linear functions

4 次查看(过去 30 天)
Hello fellows,
help me understand Matlab accuracy. I try modeling simple “zick-zack” signal:
x=0:dt:4;
slope=0.1;
h=(numel(x)-1)/4;
y(1:h+1)=x(1:h+1)*slope;
y(h+2:3*h+1)=2*y(h+1)-(x(h+2:3*h+1)*slope);
y(3*h+2:4*h+1)=4*y(3*h+1)+(x(3*h+2:4*h+1)*slope);
and the last entry of y results to be -1,11022302462516e-16. I understand that there is a limit of accuracy but why here? Can you explain it for me or point my mistake
P.S:
In the end I change script to:
y(1:h+1)=x(1:h+1)*slope;
y(h+2:3*h+1)=2*y(h+1)-(x(h+2:3*h+1)*slope);
y(3*h+2:4*h+1)=y(2:h+1)-0.1;
and now I can search for all x=0 entries

采纳的回答

Walter Roberson
Walter Roberson 2015-12-13

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Files and Folders 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by