Advertisement
Albinutte

matlab_6

Dec 24th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.50 KB | None | 0 0
  1. ns = 5 : 21;
  2. n = length(ns);
  3.  
  4. y_theory = zeros(n, 1);
  5. y_fact = zeros(n, 1);
  6. y_runge = zeros(n, 1);
  7. for i = 1 : n
  8.     y_theory(i) = 0.4 / 24 * (0.4 / ns(i)) ^ 2;
  9.     y_fact(i) = abs(Rectangle(0, 0.4, ns(i)) + exp(-0.4) - 1);
  10.     y_runge(i) = (Rectangle(0, 0.4, ns(i) * 2) - Rectangle(0, 0.4, ns(i))) / (2^2 - 1);
  11. end;
  12.  
  13. semilogy(ns, y_theory, ns, y_fact, '--', ns, y_runge, '-.');
  14. legend ('теоретическая погрешность', 'фактичекая погрешность', 'Рунге');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement