COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### How do I solve ode with variable coefficients?

• Email
• Follow

```I have an equation like that:

y"(t)*c2+y(t)*c1+c0 = 0

in which c2, c1 and c0 are also time dependent. I've already got the
time values of these coefficients, so I've only to tell to the ode
solver to changhe their value at each time step. How can I do this?

```
 0
Reply bananalimone (2) 2/22/2005 11:13:28 AM

See related articles to this posting

```Mr. Wolf wrote:
>
>
> I have an equation like that:
>
> y"(t)*c2+y(t)*c1+c0 = 0
>
> in which c2, c1 and c0 are also time dependent. I've already got
> the
> time values of these coefficients, so I've only to tell to the ode
> solver to changhe their value at each time step. How can I do this?
>

you must update values of coefficient in your ode function. you can
write a function of your coefficient and then call using feval in ode
function

ex:

dydt=zeros(10,1);
[px,py]=feval(@fonksiyon,[t,y(1),y(3),y(5),y(7),y(9)]);

dydt(1)=y(2);
dydt(2)=px-300*y(2)
dydt(3)=y(4);
dydt(4)=py-300*y(4)

tk
```
 0
Reply tkaracay6685 (1) 2/22/2005 3:36:53 PM

```try this method

for i=1:length(c1)
[T,Y]=ode45(@(t,y)system(t,y,c(i))),t,s)
Y_c(;,:,i)=Y(:,:)
end

something like this,

so Y_c(:,:,i) has every ith dimension correponding to each value fof c1 and so on :)

SALMAN```
 0
Reply salmanabdullah9 (206) 6/12/2012 12:56:12 AM

2 Replies
418 Views

Similar Articles

12/7/2013 1:20:08 PM
page loaded in 31031 ms. (0)