Show stats in bvp4c

3 vues (au cours des 30 derniers jours)
Bobby Fischer
Bobby Fischer le 4 Sep 2021
Hi, I would like to see the stats, like the number of iterations. I have 'Stats' 'on' but doesn't show anything.
Thanks for your help.
clc, clear, close all
lambda = 1;
fun = @(alpha)cosh(alpha)-4/sqrt(2*lambda)*alpha;
alpha = fzero(fun,1);
fun_exacta = @(x) 2*log(cosh(alpha)./cosh(alpha*(1-2*x)));
x = linspace(0,1);
y_exacta = fun_exacta(x);
figure(1), hold on
p3 = plot(x,y_exacta,'r','LineWidth',1.2);
x = linspace(0,1,5);
upr = @(t,u) [u(2) ; -lambda*exp(u(1))];
condcon = @(ua,ub) [ua(1)-0 ; ub(1)-0];
solinit = bvpinit(x,[0;0]);
options = bvpset('RelTol',1e-5,'Stats','on')
options = struct with fields:
AbsTol: [] RelTol: 1.0000e-05 SingularTerm: [] FJacobian: [] BCJacobian: [] Stats: 'on' Nmax: [] Vectorized: []
sol = bvp4c(upr,condcon,solinit)
sol = struct with fields:
solver: 'bvp4c' x: [0 0.2500 0.5000 0.7500 1] y: [2×5 double] yp: [2×5 double] stats: [1×1 struct]
x = linspace(0,1);
u = deval(sol,x,1);
p1 = plot(sol.x,sol.y(1,:),'b','LineWidth',1.2);
p2 = plot(x,u,'k--','LineWidth',1.2);
legend([p1 p2 p3],'Solución','deval','Exacta')

Réponses (1)

Image Analyst
Image Analyst le 4 Sep 2021
Try adding more points to your x, like
numPoints = 1000;
x = linspace(0,1, numPoints);

Catégories

En savoir plus sur Error Functions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by