Adding a vector in a system of differential equations
Show older comments
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?
Answers (1)
James Tursa
on 10 Mar 2020
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 Comments
Aria Dae
on 10 Mar 2020
James Tursa
on 10 Mar 2020
This is telling you that your equation is wrong. If iapp is a vector, how can you possibly assign it to a scalar element of the derivative? You need to re-examine the equations you are simulating and compare it to the code you have written. Or post that for us to see so we can help you.
Aria Dae
on 13 Mar 2020
James Tursa
on 16 Mar 2020
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.
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!