最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

ode23,ode113,ode45,怎么選?對比下就知道了|何必手算?Matl

2023-07-28 23:39 作者:蒼納斯  | 我要投稿


clc

close all

clear


syms y(t) t

equ = diff(y)-y+2*t/y == 0;

cond = y(0) == 1;

res = dsolve(equ, cond)

fplot(res, 'LineWidth', 2);

grid on;

hold on;


fcn = @(t, y)y-2*t/y;

tspan = [0 4];


timerValue = tic;

[t23, y23] = ode23(fcn, tspan, 1);

timer23 = toc(timerValue);

plot(t23, y23, 'LineWidth', 2);


timerValue = tic;

[t113, y113] = ode113(fcn, tspan, 1);

timer113 = toc(timerValue);

plot(t113, y113, 'LineWidth', 2);


timerValue = tic;

[t45, y45] = ode45(fcn, tspan, 1);

timer45 = toc(timerValue);

plot(t45, y45, 'LineWidth', 2);


legend('$\sqrt{1+2t}$', 'ode23', 'ode113', 'ode45', 'Interpreter', 'latex', 'Location', 'northwest');


errorfun = @(t, y)sqrt(sum((sqrt(1+2*t)-y).^2)/length(t));

ode23error = [timer23 errorfun(t23, y23)]

ode113error = [timer113 errorfun(t113, y113)]

ode45error = [timer45 errorfun(t45, y45)]

ode23,ode113,ode45,怎么選?對比下就知道了|何必手算?Matl的評論 (共 條)

分享到微博請遵守國家法律
洪江市| 凌海市| 临高县| 嘉峪关市| 泰安市| 昌乐县| 厦门市| 临西县| 福安市| 家居| 精河县| 荃湾区| 公主岭市| 榆林市| 庐江县| 延长县| 商丘市| 赤城县| 方山县| 安泽县| 双江| 屏边| 桑日县| 秦皇岛市| 罗定市| 平顶山市| 石泉县| 绥滨县| 永泰县| 富川| 焦作市| 方城县| 房山区| 盘山县| 治县。| 万州区| 察雅县| 应城市| 镇原县| 清涧县| 浪卡子县|