• Support PF! Buy your school textbooks, materials and every day products Here!

ODE solution

  • Thread starter squenshl
  • Start date
  • #1
479
4

Homework Statement


Consider the following second order ODE
$$ y'' + 2y' - y = e^{-x}, \quad y(0) = y'(0) = 1. $$ Convert this to a system of first order equations and use the pc33assisys MATLAB file to compute the solution for y(2).


Homework Equations





The Attempt at a Solution


The system of first order equations is
$$ u_1' = u_2 \\ u_2' = e^{-x}-2u_2+u_1 $$ with $$ u_1(0) = u_2(0) = 1. $$
The solution for y(2) is y(2) = 3.27 to 2 d.p. But my pc33assisys file doesn't give me this. All the relevant files are attached to run the program. Can someone help figure out what is wrong with my code.

Thanks.
 

Attachments

Answers and Replies

  • #2
818
67
There's a matrix indexing error in pc33assi3sys.m in the Adams-Moulton integration loop. Whoever wrote it also forgot to initialize f(1,:) for the first multi-step.

I've attached a corrected version.
 

Attachments

  • #3
479
4
Cheers mate
 

Related Threads on ODE solution

  • Last Post
Replies
2
Views
525
  • Last Post
Replies
7
Views
2K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
4
Views
836
  • Last Post
Replies
6
Views
1K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
3
Views
979
  • Last Post
Replies
3
Views
1K
  • Last Post
2
Replies
32
Views
1K
  • Last Post
Replies
2
Views
1K
Top