how to give initial condition as array in ode45

I want to enter initial condition of 6x6 matrix in ode45.
How to do that? Any idea.
Please help

2 件のコメント

DIP
DIP 2017 年 2 月 20 日
Sir, how do i solve an ode with an array , using ode45? ODE is udY/dx=P, Y,P are arrays.
Jan
Jan 2017 年 2 月 20 日
@DIP: Please do not attach a new question to an existing thread. Thanks.

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

 採用された回答

Star Strider
Star Strider 2014 年 4 月 29 日

0 投票

The ode45 initial conditions have to be a vector.
You have my interest, though. Why do you want them to be a matrix?

10 件のコメント

abhijit kulkarni
abhijit kulkarni 2014 年 4 月 29 日
In my program, I have one differential equation of say : Hdot= something.
Now size od Hdot is 6x6
So i have to give initial condition of 6x6
abhijit kulkarni
abhijit kulkarni 2014 年 4 月 29 日
I want use it in Kalman Filter equation.
Star Strider
Star Strider 2014 年 4 月 29 日
編集済み: Star Strider 2014 年 4 月 29 日
No, you don’t need a matrix of initial conditions.
You need a (6x1) vector of initial conditions, since you have a system of 6 differential equations, each an expression for the derivative of one of your variables.
The vector should work.
EDIT — I’ll have to go back to my Kalman filter books to understand what you might be doing (too tired tonight), but what I mentioned about the initial condition vector for ode45 is correct.
abhijit kulkarni
abhijit kulkarni 2014 年 4 月 29 日
If I send you the code is, it possible to rectify the error?
Please help me.
abhijit kulkarni
abhijit kulkarni 2014 年 4 月 29 日
Pdot = F * P + P * F' + Q - P * H' *inv® * H * P;
Here P dot is a 6x6 matrix. Yes it is diagonal matrix. Still I dont know how to enter the initial condition.
abhijit kulkarni
abhijit kulkarni 2014 年 4 月 29 日
Ok take rest.
Thanks for immediate reply. Good night
Star Strider
Star Strider 2014 年 4 月 29 日
Don’t send it to me, instead post it as an attachment to your original Question (use the ‘paper-clip’ icon in the toolbar above the window). That way, if I can’t answer it, there are others here on MATLAB Answers who probably can, and will be able to read and run your code. If you send it only to me, others will not have access to it.
Star Strider
Star Strider 2014 年 4 月 29 日
I don’t know exactly what the initial conditions for your system are, but a vector of zeros will likely work unless you know they will not. If you have a function file or anonymous function for Pdot, call ode45 this way:
% For a function file for |Pdot| named |Pdot.m|:
[T, P] = ode45(@Pdot, tspan, zeros(6,1));
% For an anonymous function such as:
F = [matrix];
P = [matrix];
Q = [matrix];
R = [matrix];
H = [matrix];
Pdot = (t,p,F,P,Q,R,H) F * P + P * F' + Q - P * H' * R \ H * P;
[T, P] = ode45(@(t,p) Pdot(t,p,F,P,Q,R,H), tspan, zeros(6,1));
You will have to define F, P, Q, R, H. I cannot test this code because I do not have all your information. However, it should work. (Note that I replaced inv( R ) * H by R \ H. That is more efficient and will produce a more accurate result.)
abhijit kulkarni
abhijit kulkarni 2014 年 4 月 29 日
Respected Star Thank you very much!
I thought I took much time of your rest.
Well I have Pdot equation as one of the two more differential equations.
What I did is that as you said : I put initial condition of 6 variables (diagonal) of P initial matrix. And then inside program, I equated them in for loop with eye(y).
Any way your help and attitude to help is simply great.
In gratitude Abhijit
Star Strider
Star Strider 2014 年 4 月 29 日
My pleasure!
I am happy it worked.

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

その他の回答 (0 件)

カテゴリ

質問済み:

2014 年 4 月 29 日

コメント済み:

Jan
2017 年 2 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by