Cody

Problem 231. Differential equations I

Solution 112445

Submitted on 14 Jul 2012 by Freddy
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
%% f = @(x) -x; tf =1; y0 =1; assert(abs(deqnsolve(f,y0,tf)-exp(-1)) < 1e-5)

x = solver: 'ode45' extdata: [1x1 struct] x: [1x11 double] y: [1x11 double] stats: [1x1 struct] idata: [1x1 struct] ans = 0.3679

2   Pass
%% f = @sin; tf =1; y0 =1/2; assert(abs(deqnsolve(f,y0,tf)-2*acot(exp(-1)*cot(1/4))) < 1e-5)

x = solver: 'ode45' extdata: [1x1 struct] x: [1x11 double] y: [1x11 double] stats: [1x1 struct] idata: [1x1 struct] ans = 1.2135

3   Pass
%% f = @(x) 1/(x+1); tf =6; y0 =1; assert(abs(deqnsolve(f,y0,tf)-3) < 1e-5)

x = solver: 'ode45' extdata: [1x1 struct] x: [1x12 double] y: [1x12 double] stats: [1x1 struct] idata: [1x1 struct] ans = 3.0000

4   Pass
%% a randomized one a = rand*0.9; f = @(x) x-a*x^2; tf = rand+1.5; y0=1; assert(abs(deqnsolve(f,y0,tf)-exp(tf)/(1-a+a*exp(tf))) < 1e-5)

x = solver: 'ode45' extdata: [1x1 struct] x: [1x11 double] y: [1x11 double] stats: [1x1 struct] idata: [1x1 struct] ans = 1.3390

Community Treasure Hunt

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

Start Hunting!