How to use "deval" or any other function non ode solver output

조회 수: 7 (최근 30일)
Romio
Romio 2023년 8월 3일
편집: Torsten 2023년 8월 3일
Suppose I have a solution to an ode that I obtained numerically using an accurate method that is close to the exact solution. Call it Y_exact which may be of size 2 x 1000, where 2 is for the two solution components, and 1000 is the number of time points. Suppose I have another solution by a differnt method Y of size 2 x n where n <= 1000. Let tout = 1:dt:n
Now if Y_exact obtained with ode45 or any other solver, I could obtain exact solution at the same time points by doing deval(sol,tout) where sol is the solution structure obtained from ode45.
Now since Y_exact in my case is not obtained with a matlab solver, and is just a vector, is there any way to use deval() or any other way to match Y and Y_exact at the same time points? So that I can compute the error norm(Y - Ytrue,'inf').

채택된 답변

Torsten
Torsten 2023년 8월 3일
편집: Torsten 2023년 8월 3일
Y_exact_to_Y = interp1(T_exact,Y_exact,tout)
where T_exact is the vector of time points corresponding to Y_exact.
Further, you can choose the method of interpolation. Read

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Nonlinear ARX Models에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by