Matlab take a long time for evaluation

1 view (last 30 days)
Wajahat
Wajahat on 9 Oct 2018
Commented: Jan on 9 Oct 2018
When I evaluate the program (given below), matlab take a long time to evaluate this program. How to get rid off from this problem?
syms x
D=0.1;
k1=-0.5; c1=1; a=1; b=2;
C=1+c1*exp(k1*x);
u0=diff(log(C),x);
u0=inline(u0);
x=[-50:D:50];
u0=u0(x);
options=odeset('RelTol',1e-4,'AbsTol',1e-8);
[t u]=ode45(@dydt, [0:D^3:40], u0, options);
T=t;
X=[-50:D:50];
[t,x]=meshgrid(T,X);
u=u';
t=t(:,1:8000:40001);
x=x(:,1:8000:40001);
U=u(:,1:8000:40001);
plot3(x,t,U,'.')
axis([-50 50 0 40 -0.5 0])
  1 Comment
Jan
Jan on 9 Oct 2018
What does "a long time" mean exactly? Too many seconds or weeks? You did not post the code for |dydt|. Did you check if the ODE is stiff? Then ODE45 is a bad choice. The absolute tolerance of 1e-8 might be too small for an efficient integration. BY the way, see <http: how to format code in the forum>. There is no need for square brackets around vectors, this is sufficient already: |X=-50:D:50;|. </http:>

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!