• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jun 3rd, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. % W ramach pakietu octave napisz skrypt obliczajacy nastepujace dzialania na macierach
2. % A*B
3. % A^T * B^T
4. % X gdy A * B * X = Y
5. %
6. %
7.
8. A = [ 2,3,9,2,9;
9.       2,5,2,1,1;
10.       6,1,8,3,1];
11.
12. B = [ 6,7,7;
13.       9,2,3;
14.       2,5,1;
15.       6,0,7;
16.       0,3,2];
17.
18. Y = [ 440;
19.       427;
20.       372];
21.
22. F = zeros(3,3)
23. [l_kA,l_wA] = size(A);
24. [l_kB,l_wB] = size(B);
25.
26. if(l_wA==l_kB)
27.
28. for i=1:3
29.   for j=1:3
30.     F(i,j)=A(i,1)*B(1,j)+A(i,2)*B(2,j)+A(i,3)*B(3,j)+A(i,4)*B(4,j)+A(i,5)*B(5,j)
31.   endfor
32. endfor
33. disp("WYNIK\n");
34. disp(F);
35. disp("POPRAWNY\n");
36. disp(A*B);
37. else
38. disp("nie mozna wymnozyc macierzy");
39. end
40.
41.
42. C = zeros(l_wA,l_kA);
43. for i=1:l_wA
44.   for j=1:l_kA
45.   C(i,j)=A(j,i);
46.   end
47. end
48. disp("Poprawne\n");
49. disp(A.');
50. disp("obliczone\n");
51. disp(C);
52.
53. % X = F^-1 * Y
54.
55. [lwF,lkF] = size(F)
56.
57. if(det(F)!=0)
58. MF = zeros(lwF-1,lkF-1)
59. for i=1:lwF
60.   for j=1:lkF
61.     w=1;
62.     for p=1:lwF
63.       if p!=i
64.         k=1;
65.         for t=1:lkF
66.           if t!=j
67.             MA(w,k) = F(p,t);
68.             k = k + 1;
69.           end
70.         end
71.         w = w + 1;
72.       end
73.     end
74.     D(i,j) = MA(1,1)*MA(2,2)-MA(2,1)*MA(1,2);
75.     D(i,j) = D(i,j)*(-1)^(i+j);
76.   end
77. end
78. disp(D);
79.
80. for i=1:lwF
81.   for j=1:lkF
82.   DT(j,i)=D(i,j);
83.   end
84. end
85. F_odt = (1/det(F))*DT;
86.
87. disp(F_odt);
88. disp("\n");
89. disp(inv(F));
90.
91. else
92. disp("nie mozna");
93. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top