How to integrate linear system of vectorial equations?
2 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have the following system of vectorial equations that describe a curve in space r, its tangent vector t and its normal $n$, parametrised by the arc length s:
Suppose I have the function given as a vector of values, as well as initial values of r, t and n. Then is there some simple way (or package) for numerically integrating this system of vectorial equations?
Thank you very much!
1 件のコメント
採用された回答
Star Strider
2021 年 8 月 20 日
syms kappa n(s) r(s) s t(s) r0 t0 n0 Y
Eqn = [diff(r) == t; diff(t) == -r + kappa*n; diff(n) == -kappa*t];
rtn = dsolve(Eqn, r(0)==r0, t(0)==t0, n(0)==n0)
t = simplify(rtn.t, 500)
r = simplify(rtn.r, 500)
n = simplify(rtn.n, 500)
Alternatively:
[VF,Subs] = odeToVectorField(Eqn)
rtnfcn = matlabFunction(VF, 'Vars',{s,Y,kappa})
Use ‘rtnfcn’ with the approopriate numeric ODE solver (for example 0de45, ode15s) depending on the magnitude of κ.
For example:
sspan = linspace(0,10); % Vector Of 's' Values
initconds = rand(3,1); % Initial Conditions
[s,rtn] = ode15s(@(s,rtn,kappa), sspan, initconds); % Integrate
figure
plot(s, rtn)
grid
.
4 件のコメント
Star Strider
2021 年 8 月 22 日
As always, my pleasure!
‘Is there a typo in `ode15s(@(s,rtn,kappa), sspan, initconds)`? ’
There is. It should be:
[s,rtn] = ode15s(@(s,rtn) rtnfcn(s,rtn,kappa), sspan, initconds); % Integrate
‘Can I use `rtnfcn` with a boundary-value solver like `bvp4c`?’
Probably. One addition would be to create ‘kappa’ as an anonymous function, for example with ‘s’ as the independent variable and ‘kapa’ as the dependent variable:
kapamtx = [s(:) kapa(:)];
kappa = @(s) interp1(kapamtx(:,1), kapamtx(:,2), s);
It would be necessary either to keep ‘s’ within the limits of ‘kapamtx(:,1)’ in order to avoid either extrapolating or returning NaN values for ‘s’ outside that range.
.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Numerical Integration and Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!