calculating maximum error

조회 수: 26 (최근 30일)
Jonathan
Jonathan 2012년 5월 15일
댓글: Mounir guesbaya 2019년 3월 31일
I created an vector in matlab that represents an object moving at a velocity v(t) = 5 + 7*t^2 starting from the position x(2) = 5 at t = 2. This vector is called x and is: x2 + 5*t + 7*t.^3/3 (x2 equals 5) (this vector was solved analytically, i.e. I just integrated the velocity function. The next vector, called xtrap, was created using MATLAB's cumtrapz function: xtrap = cumtrapz(t,v) + x2.
How do I calculate the maximum error between these two solutions? Thanks.

채택된 답변

Wayne King
Wayne King 2012년 5월 15일
max(abs(x-xtrap))
If you want to know which index in the vector was the largest difference
[maxdiff,Index] = max(abs(x-xtrap));
Another way is
norm(x-xtrap,Inf)
but that way, you don't get the index
  댓글 수: 2
Jonathan
Jonathan 2012년 5월 15일
Thanks! This is very helpful.
Mounir guesbaya
Mounir guesbaya 2019년 3월 31일
Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by