- #1
Void123
- 141
- 0
I'm looking at the following example (http://www.cyclismo.org/tutorial/matlab/control.html):
y'=x^2-y^2, y(0)=1, where they use the Euler method to approximate numerical solutions.
This is the code:
I don't understand the third and fourth line at the top. What is [tex]y = 0*x[/tex] and how did they get y(1) = 1...?
Thanks.
y'=x^2-y^2, y(0)=1, where they use the Euler method to approximate numerical solutions.
This is the code:
>> h = 0.1;
>> x = [0:h:2];
>> y = 0*x;
>> y(1) = 1;
>> size(x)
ans =
1 21
>> for i=2:21,
y(i) = y(i-1) + h*(x(i-1)^2 - y(i-1)^2);
end
>> plot(x,y)
>> plot(x,y,'go')
>> plot(x,y,'go',x,y)
I don't understand the third and fourth line at the top. What is [tex]y = 0*x[/tex] and how did they get y(1) = 1...?
Thanks.
Last edited: