what is the efficient method in matlab to solve non-linear explicit differential equation???

2 views (last 30 days)
I have tried two methods for it that give different results:
1... dsolve command dont give any suitable numeric result.
The code statement is: A(i) = dsolve('DA=m(i)*(1/(1+exp(0.5-A)))','A(0)=0')
2... ode45 function developed and used by me also do not give a numerical value even I input the function an initial condition as well time limit for integration. Then why it results in an array. I want one numeric value that may provide me with the further processing in the code satisfactorily. Otherwise if the result as an array is acceptable then my question is how to use this array as one effective number for one iteration . The code is:
_function [dA_dt] = shahid(t,A)
global m
global i
dA_dt=m(i)*(1/(1+exp(0.5-A)));
return
.................
[t,A{i}]=ode45(@shahid,[0,1],0) %%%Here the function is called in main program within a loop of an index variable 'i'.
Note: m(i) is a constant real number different for different iterations.

Answers (1)

Sara
Sara on 26 Jun 2014
" Then why it results in an array ": ode45 will choose the timestep and adjust it during the integration. It returns ALL the times where the function was calculated. Provide an array of times in input if you want the function to be calculated only at certain times. Otherwise, if you only need the value of you variable A at the end of the time interval, simply do A{i} = A{i}(end); after the call to ode45.

Community Treasure Hunt

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

Start Hunting!