标签:atl for plot div hid gif splay class cli
实习题1:
将xx化成一阶方程组,并用Euler法和改进的Euler法求解,步长h = 0.1, 0.05。
画出Euler法,Euler改进法以及精确解的数值结果图形
clear all; clc; h1 = 0.05; len = 1 + 1 / h1; u = zeros(1, len); v = zeros(1, len); t = zeros(1, len); exact = zeros(1, len); u(1) = 0; v(1) = 1; t(1) = 0; exact(1) = 0; for i = 1:len-1 t(i + 1) = i * h1; u(i + 1) = u(i) + h1 * v(i); v(i + 1) = v(i) - h1 * u(i); exact(i + 1) = sin(h1 * i); end u1 = zeros(1, len); v1 = zeros(1, len); u1(1) = 0; v1(1) = 1; for i = 1:len-1 u1(i + 1) = ((1 + h1 * h1 / 4) * u(i) + h1 * v(i)) / (1 - h1 * h1 / 4); v1(i + 1) = v1(i) + (u1(i) + u1(i + 1)) * h1 / 2; end plot(t, u, ‘r*‘, ‘markersize‘, 10); hold on plot(t, u1, ‘r.‘, ‘markersize‘, 20); hold on plot(t, exact); grid on
标签:atl for plot div hid gif splay class cli
原文地址:https://www.cnblogs.com/lwqq3/p/13053746.html