I am solving ODE by using ode23, ode45 and ode113 in Scilab, I am going to compute the mean absolute error to check which one is more accurate, but all solvers give the error is equal to 0 and the vector length is the same for all of them n=100. I see there is something wrong here and it does not match with MATLAB results. can you help, please? I am going to attach my code.
clear
function [v] = functiondifference(t,y,exact)
[row,column] = size(t); // size(A) returns the dimensions of a matrix A. In our case t is a column vector
for k = 1:row
v(k) = feval(t(k),exact) - y(k); /////////////////////note
end
endfunction
function y = exact(t)
y = -3-exp(-sin(t)/2);
endfunction
function yp=de(t,y)
yp=-(3+y/2)*cos(t)
endfunction
function dydt=f(t,y)
y=y(1);
dydt=[ -(3+y/2)*cos(t)]
endfunction
t=linspace(0,%pi);
y0=-4;
//ode 23
y = ode("adams", y0, 0, t, f); //t0=0
err=functiondifference(t,y,exact)
Error=mean(abs(err))
L=length(y)
disp(L)
//ode 45
y1 = ode("rkf", y0, 0, t, f);
err1=functiondifference(t,y,exact)
Error1=mean(abs(err1))
L1=length(y1)
disp(L1)
//ode 113
y2= ode(y0, 0, t, f);
err2=functiondifference(t,y2,exact)
Error2=mean(abs(err2))
L2=length(y2)
disp(L2)
Thanks for your help. the exact solution is correct for the given differential equation yp=0.5*(3+y)*cos(t) and still the output is not correct even after changing in the function to [row,column] = size(t'). I am going to attach
MATLAB results and the exact solution. Thanks in advance.
