worms005

Laborka

Nov 15th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.18 KB | None | 0 0
  1. A1= [2 4 6 7; 3 6 5 5; 4 2 3 2; 5 1 2 6];
  2. A2= [1 2 3; 4 5 6; 7 8 9]; %macierz zle uwarunkowana
  3. A3= [0 0 0; 4 5 6; 7 8 9];
  4.  
  5. b1= [21 18 12 15];
  6. b2= [4 10 16];
  7.  
  8. mnoz1= A1*inv(A1)
  9. mnoz2= A2*inv(A2)
  10. mnoz3= A3*inv(A3)
  11.  
  12. condA1= cond(A1); %wspolczynnik uwarunkowania macierzy
  13.                   %||A||/||inv(A)|| = cond(A) > 200 macierz ma trudne wlasnosci
  14. condA2= cond(A2)
  15. condA3= cond(A3)
  16. deta2= det(A2)
  17.  
  18. %A1*x1= b1'
  19. x1= inv(A1)* b1' %b' - transponowana
  20. E1= A1* x1- b1' %wektor bledu
  21. e1= norm(E1) %dlugosc wektora bledu
  22.  
  23. x2= inv(A2)* b2'
  24. E2= A2* x2- b2'
  25. e2= norm(E2)
  26.  
  27. x22= A2\ b2' %\ - metoda Gaussa
  28. E22= A2* x22 -b2'
  29. e22= norm(E22)
  30.  
  31. %III
  32. x= 0 : 0.2 : 10*pi;
  33. y1= exp(-x/10);
  34. y2= y1.* sin(4*x);
  35. y3= -y1;
  36.  
  37. hold on
  38. figure(1);
  39. plot(x, y1, 'r')
  40. plot(x, y2, 'k')
  41. plot(x, y3, 'b')
  42. hold off
  43.  
  44. %IV
  45. figure(2);
  46. [x,y]= meshgrid(-3 : 0.2 : 3);
  47. z= sin(x).*sin(y).*exp(-x.^2- y.^2);
  48. subplot(2,2,1);
  49. mesh(x, y, z);
  50. shading interp
  51. subplot(2,2,2);
  52. surf(x, y, z);
  53. shading interp
  54. subplot(2,2,3);
  55. surfc(x, y, z);
  56. shading interp
  57.  
  58. %V
  59. zet= @(x) sin(x(1))*sin(x(2))*exp(-x(1)^2- x(2)^2);
  60. [x, fval2]= fminsearch(zet, [-0.7, 0.7])
  61. [x, fval4]= fminsearch(zet, [0.7, -0.7])
Advertisement
Add Comment
Please, Sign In to add comment