Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 1.55 KB | None | 0 0
  1. x = 0: 0.1: 4;
  2.  
  3. deff('y = f(x)','y = (16 - x^2)^(1/2)');
  4. y = f(x);
  5.  
  6. //draw
  7. xgrid();
  8. plot2d(x, y);
  9.  
  10. k = splin(x, y);
  11. t = 0: 1: 4;
  12. spl = interp(t, x, y, k);
  13. plot2d(t, spl, -10);
  14. plot2d(f(1),1,-10);
  15.  
  16. t(6) = t(5);
  17. spl(6) = spl(5);
  18. spl(5) = 1.0;
  19. t(5) = 3.87;
  20.  
  21. //table of coordinates
  22. disp("x   -   y");
  23. for i = 1:1:length(t)
  24.     mprintf('%2.2f - %2.2f\n', t(i), spl(i));
  25. end
  26.  
  27. //u(x, y)
  28. function u = Calc_U(x, y)
  29.     u = 0.5 * abs(x) + abs(y);
  30. endfunction
  31. for i = 1:1:length(t)
  32.     u(i) = Calc_U(t(i), spl(i));
  33. end
  34.  
  35. disp("U(x, y) = 0.5 * |x| + |y|");
  36. for i = 1:1:(length(t))
  37.     mprintf('U(%5.2f, %5.2f) = %5.2f\n', t(i), spl(i), u(i));
  38. end
  39.  
  40. //Matrix A
  41. A = [ 4 -2  0 -1  0  0  0  0  0  0  0  0  0  0  0;
  42.      -1  4 -1  0 -1  0  0  0  0  0  0  0  0  0  0;
  43.       0 -1  4  0  0 -1  0  0  0  0  0  0  0  0  0;
  44.      -1  0  0  4 -2  0  0 -1  0  0  0  0  0  0  0;
  45.       0 -1  0 -1  4 -1  0  0 -1  0  0  0  0  0  0;
  46.       0  0 -1  0 -1  4 -1  0  0 -1  0  0  0  0  0;
  47.       0  0  0  0  0 -1  4  0  0  0 -1  0  0  0  0;
  48.       0  0  0 -1  0  0  0  4 -2  0  0 -1  0  0  0;
  49.       0  0  0  0 -1  0  0 -1  4 -1  0  0 -1  0  0;
  50.       0  0  0  0  0 -1  0  0 -1  4 -1  0  0 -1  0;
  51.       0  0  0  0  0  0 -1  0  0 -1  4  0  0  0 -1;
  52.       0  0  0  0  0  0  0  0 -4  0  0  4  0  0  0;
  53.       0  0  0  0  0  0  0  0 -2  0  0 -1  4 -1  0;
  54.       0  0  0  0  0  0  0  0  0 -2  0  0 -1  4 -1;
  55.       0  0  0  0  0  0  0  0  0  0 -1  0  0 -1  4;];
  56. B = [4; 4.37; 8.92; 0; 0; 0; 8.3; 0; 0; 0; 2.94; 0; 0; 0; 0;];
  57.  
  58. C=rref([A B]);
  59. [n,m]=size(C);
  60. x=C(:,m)
  61.  
  62. disp(x);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement