Show stats in bvp4c

조회 수: 1 (최근 30일)
Bobby Fischer
Bobby Fischer 2021년 9월 4일
답변: Image Analyst 2021년 9월 4일
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')

답변 (1개)

Image Analyst
Image Analyst 2021년 9월 4일
Try adding more points to your x, like
numPoints = 1000;
x = linspace(0,1, numPoints);

카테고리

Help CenterFile Exchange에서 Boundary Value Problems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by