필터 지우기
필터 지우기

How to integrate linear system of vectorial equations?

조회 수: 1 (최근 30일)
Anshuman Pal
Anshuman Pal 2021년 8월 20일
댓글: Star Strider 2021년 8월 22일
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
Wan Ji
Wan Ji 2021년 8월 20일
편집: Wan Ji 2021년 8월 20일
Use ode45 or other ode tools

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
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)
rtn = struct with fields:
t: [1×1 sym] r: [1×1 sym] n: [1×1 sym]
t = simplify(rtn.t, 500)
t = 
r = simplify(rtn.r, 500)
r = 
n = simplify(rtn.n, 500)
n = 
Alternatively:
[VF,Subs] = odeToVectorField(Eqn)
VF = 
Subs = 
rtnfcn = matlabFunction(VF, 'Vars',{s,Y,kappa})
rtnfcn = function_handle with value:
@(s,Y,kappa)[kappa.*Y(3)-Y(2);Y(1);-kappa.*Y(1)]
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
Anshuman Pal
Anshuman Pal 2021년 8월 22일
Thank you! A couple more comments:
1) Is there a typo in `ode15s(@(s,rtn,kappa), sspan, initconds)`? Shouldn't it be `ode15s(@rtnfcn, sspan, initconds)`?
2) Can I use `rtnfcn` with a boundary-value solver like `bvp4c`?
Star Strider
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 CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by