Adding a vector in a system of differential equations

1 回表示 (過去 30 日間)
Aria Dae
Aria Dae 2020 年 3 月 10 日
コメント済み: James Tursa 2020 年 3 月 16 日
I have a system of odes to be solved. The problem is that one of the odes contains iapp, which is a vector (same size as the time vector) i have from experimental data.
[time,output]=ode113('DiffEquations',time,init);
with:
function [output] = DiffEquations(time,init)
% defining variables and constants ...
% output(1,1)=....
% output(2,1)=(....
output(3,1)=(-iNa-iK+iapp)/C;
end
How should i input this vector in the function?

回答 (1 件)

James Tursa
James Tursa 2020 年 3 月 10 日
One way is to create a function handle to pass in the extra parameters. E.g.,
function [output] = DiffEquations(time,init,iapp) % <-- add iapp to the input argument list
Then in your calling code:
[time,output]=ode113(@(t,y)DiffEquations(t,y,iapp),time,init); % <-- function handle with iapp
  4 件のコメント
Aria Dae
Aria Dae 2020 年 3 月 13 日
Sorry for the confusion, i am not explaining myself well. Basilly, i have two vectors of data, the time vector and an Iapp vector (of the same size). What I am trying to compute is the voltage vector ( output(3,1) in the system of odes ) , which can be computed as such : dv/dt=(-iNa-iK+iapp)/C. The first two terms are expressed as functions of time which i wrote above. The iapp term, however, i have as a vector and i don't know how i can add the value of iapp at each second to the corresponding voltage at the same time.
Sorry again for the confusion, and thank you for the help!
James Tursa
James Tursa 2020 年 3 月 16 日
If you don't know, then that means you don't understand your own set of odes. Is iapp perhaps a time sequence of values that you would need to interpolate? Again, we are guessing here until you can post the odes for us to look at.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by