Skip to content
Permalink
fdd7e99917
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
21 lines (19 sloc) 357 Bytes

06_initial_value_ode

Problem 2

Part A

The analytical solution to y' = -y is y = e^-t

Part B

dt=[0.5 .1 .001];
figure();
hold on
     x=[0:dt(2):3]';
     y_n=zeros(size(x));
    y_n(1)=1;
for i=2:length(x)
    dy=prob2_ode(x,y_n(i-1));
    y_n(i)=y_n(i-1)+ dt(2)*dy;
end  
plot(x,exp(-x),'k-',x,y_n,'o');