Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all; clc;
- x = 0;
- y = 0;
- x_vek = 0;
- y_vek = 0;
- h = 0.2;
- hh = 0.2;
- eh = [];
- for i = 1:5
- N = 5/h;
- x_vek = [];
- for j = 1:N
- x(j+1) = x(j) + (h.*deriv(x(j)));
- x_vek = [x_vek,x(j+1)];
- end
- plot(x_vek);
- hold on;
- h = h/2;
- end
- legend = legend('h = 0.2', 'h=0.1', 'h=0.05', 'h = 0.025', 'h = 0.0125');
- xlabel('Antal iterationer');
- ylabel('Numeriska approximationer av x(t)');
- function der = deriv(a)
- der = 125./(a+5);
- end
- function es = xe(t)
- es = sqrt(250.*t + 25) -5;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement