Re: [問題] ODE45 解有矩陣的微分方程
※ 引述《swiminwine (陳小黑)》之銘言:
: 安安
: 我要解一個微分方程 例如
: y''+2y'+4y=2*Cos(5*t) , y(0)=5 , y'(0)=2
: 這種等號右邊是函數的 我會解 ex: cos(t) ,exp(t.^2) 等等
: 但我現在面對的問題是 等號右邊是一個一維向量
: 例如 y''+2y'+4y=AA(t) ; AA=[3 5 7 9 11 ...]
: 坐標軸對應到的 t=[0 1 2 3 4 5 6...]
: 我有試著把AA寫成function 可以呼叫
: 但是在ode45 的函數就出現error
: error codes
: Error in odearguments (line 88)
: f0 = feval(ode,t0,y0,args{:}); % ODE15I sets
: args{1} to yp0.
: Error in ode45 (line 114)
: [neq, tspan, ntspan, next, t0, tfinal, tdir, y0,
: f0, odeArgs, odeFcn, ...
: 有什麼方法可以解決這個問題
: 謝謝
AA(t) = [3 5 7 9 11]
可以擬似為 AA(t) = 3+2*t
---------------------------------------------------
function pttex137
% AA(t) = [3 5 7 9 11...]
% 可近似於 AA(t) = 3+2*t
[t,y]=ode45(@trydo,[0 4],[5;2])
plot(t,y)
title('擬似矩陣輸入函數')
xlabel('t')
ylabel('y')
legend('y','y''')
grid
function f = trydo(t,x)
% x1' = x2 = x'
% x2' = x1'' = x''
f(1) = x(2);
f(2) = 3+2.*t - 2.*x(2) - 4.*x(1);
f = f';
----------------------------------------------------
假如是不連續的函數,如步階函數累加
就需要用拉氏轉換來解,MATLAB裡面也有函數可以解
--
1.MATLAB programming 2.ASPEN process simulation package
3.FORTRN programming 4.Advance Engineering Mathematics
5.Process Control Theory
6.Chemical Engineering Basic Theory(Kinetic.thermodynamics.transport)
7.Numerical Method and Analysis
8.MATLAB Toolbox.Simulink system basic design
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 113.163.21.45
推
11/18 17:46, , 1F
11/18 17:46, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):