matlab accuracy in linear functions

조회 수: 8 (최근 30일)
Immelmann
Immelmann 2015년 12월 13일
답변: Walter Roberson 2015년 12월 13일
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