필터 지우기
필터 지우기

ODE- How to solve this equation??

조회 수: 2 (최근 30일)
inbal kashany
inbal kashany 2011년 6월 1일
Hi Im trying to solve this differential equation:
dydt=((g0.*L-y)./tau)-((Pin./Esat)*(exp(y)-1));
by ODE45: [T Y]=ode45(@(t,y) fun(t,Y,It,I),[0 3],0);
but it doesnt work... I guess becouse it based on example3 from ODE45 help which looks like this: dydt = -f.*y + g,(y'(t) + f(t)y(t) = g(t))
but here I have the "exp(y)" which I dont know how to hadle with.
g0=R*a*n0*((I/I0)-1); I is a vector dependent on t. L,tau,Pin,Esat,R,a,n0,I0 are constant.
any suggestion may help. thanks
  댓글 수: 1
Arnaud Miege
Arnaud Miege 2011년 6월 1일
Please reformat your code. See http://www.mathworks.co.uk/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer

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

답변 (3개)

Igor
Igor 2011년 6월 1일
be exactly in y(t) definition and remember that y(t) is a COLUMN vector.
also in -- @(t,y) fun(t,Y,It,I) -- you use y and Y!

Laura Proctor
Laura Proctor 2011년 6월 1일
The following code worked for me:
dydt=@(t,y)(((g0*L-y)/tau)-((Pin/Esat)*(exp(y)-1)));
[T Y]=ode45(dydt,[0 3],0);
But, I did have to make some guesses at the constant values, such as g0, L, tau, Pin, and Esat.
  댓글 수: 1
inbal kashany
inbal kashany 2011년 6월 2일
g0 is not constant-
g0=R*a*n0*((I/I0)-1);
I=[zeros(10,1);ones(10,1);zeros(10,1);]; %step signal%%
It=linspace(0,30,30); %generate t for I
I=interp1(It,I,t); % Interpolate the data set (It,I) at time t
now I got the error: odearguments at 115 @(T,H)(((G0*L-H)/TAU)-((PIN/ESAT)*(EXP(H)-1))) returns a vector of length 30, but the length of initial conditions vector is 1. The vector returned by @(T,H)(((G0*L-H)/TAU)-((PIN/ESAT)*(EXP(H)-1))) and the initial conditions vector must have the same number of elements.
*h replace y
I'll be happy get an answer.

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


inbal kashany
inbal kashany 2011년 6월 2일
Thanks to both of you for your replay.
g0 is not constant-
g0=R*a*n0*((I/I0)-1);
I=[zeros(10,1);ones(10,1);zeros(10,1);]; %step signal%%
It=linspace(0,30,30); %generate t for I
I=interp1(It,I,t); % Interpolate the data set (It,I) at time t
now I got the error: odearguments at 115 @(T,H)(((G0*L-H)/TAU)-((PIN/ESAT)*(EXP(H)-1))) returns a vector of length 30, but the length of initial conditions vector is 1. The vector returned by @(T,H)(((G0*L-H)/TAU)-((PIN/ESAT)*(EXP(H)-1))) and the initial conditions vector must have the same number of elements.
*h replace y
I'll be happy get an answer.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by