bvptest.m

来自「(有源代码)数值分析作业,本文主要包括两个部分,第一部分是常微分方程(ODE)的」· M 代码 · 共 30 行

M
30
字号
% function bvptest
solinit = bvpinit([0 1 2 3 4],[100; 0]);
sol = bvp4c(@twoode, @twobc, solinit);

xint = linspace(0, 4, 50);
yint = deval(sol, xint);
plot(xint, yint(1,:),'b');
xlabel('x')
ylabel('solution y')
% hold on

%%
% This particular boundary value problem has exactly two solutions.  The other
% solution is obtained for an initial guess of 
% 
%     y(x) = -1, y'(x) = 0 
% 
% and plotted as before.

hold on
clear
solinit = bvpinit([0 1 2 3 4],[-100; 0]);
sol = bvp4c(@twoode,@twobc,solinit);

xint = linspace(0,4,50);
yint = deval(sol,xint);
plot(xint,yint(1,:),'r');

legend('solinit +100','solinit -100')
title('BVP')

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?