- #1
theBEAST
- 364
- 0
Homework Statement
I want to find the maximum value of x given that the differential equation relating x is:
x' = 0.7548 - 599.49x^6 -2.4038x^2 - 0.12236x^1.5
Where x = 0 at t = 0.
I have to do this with MATLAB using Euler's Method and here is my code:
Code:
x = 0
a = 0 % initial t value
b = 1000 % final t value
N = 1000 % number of intervals
for i = 1:N-1
x(i+1) = x(i) + (b-a)/N * (0.7546-599.49*x(i)^6 - 2.4038*x(i)^2 - 0.12236*x(i)^1.5)
end
max(x)
I get an imaginary number for the value... And most of the numbers in the vector x are NaN + NaNi.
Does anyone know what I am doing wrong?