📄 ex1.m
字号:
function [out] = Ex1(x, y, flag)%% Evaluate the right hand side function for the% ODE% % y_1'(x) = y_2(x)% % y_2'(x) = 4*y_1(x) + 3*y_2(x) - 8*exp(x) * cos(2x)% %% This system is equivalent to the second order ODE%% z''(x) - 3 z'(x) - 4 z(x) = - 8 exp(x) * cos(2x)%% The exact solution of the system with initial conditions%% y_1(0) = 2 + 10/13 % y_2(0) = 3 + 14/13%% is given by% y_1(x) = exp(-x) + exp(4*x) % + 10/13 * exp(x) * cos(2x) + 2/13 * exp(x) * sin(2x)% % y_2(x) = -exp(-x) + 4 * exp(4*x) % + 14/13 * exp(x) * cos(2x) - 18/13 * exp(x) * sin(2x)%switch( flag ) case '' % return right hand side out = [ y(2); 4*y(1) + 3*y(2) - 8*exp(x) .* cos(2*x) ]; case 'jacobian' % return Jaacobian of right hand side out = [ 0 1; 4 3 ]; otherwise error (['Unknown request.'])end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -