Advertisement
Guest User

mn

a guest
Jun 24th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 1.06 KB | None | 0 0
  1.  Grupa czerwona:
  2. % Zadanie 1
  3. x1 = -5 : 0.01 : -0.01;
  4. x2 = 0 : 0.01 : 5;
  5.  
  6. f1 = @(x) cos(x.^2);
  7. f2 = @(x) 1 ./(x+1);
  8.  
  9. plot(x1, f(x1), "r", x2, f(x2), "r")
  10.  
  11.  
  12. % Zadanie 2
  13. C = randi(5, 5)
  14. C(C != 1)
  15.  
  16.  
  17. % Zadanie 3
  18. A = randi(5, 5)
  19. n = size(A, 1);
  20. B = triu(ones(n)) & fliplr(triu(ones(n)));
  21. sum(A(B))
  22.  
  23.  
  24. % Zadanie 4
  25.  x(1)=3;
  26.  y(1)=4;
  27.  z(1)=5;
  28.  for n=1:3
  29.    x(n+1)=3*x(n)+2*z(n)+1;
  30.    y(n+1)=3*x(n)+2*z(n)+2;
  31.    z(n+1)=4*x(n)+3*z(n)+2;
  32.  endfor
  33.  for n=1:4
  34.    disp([num2str(x(n)^2)," + ",num2str(y(n)^2)," = ",num2str(z(n)^2)])
  35.  endfor
  36.  
  37.  
  38.  
  39.  Grupa czarna:
  40. % Zadanie 1
  41. x1 = -2 : 0.01 : 0;
  42. x2 = 0 : 0.01 : 2;
  43.  
  44. f1 = @(x) sin(x.^5);
  45. f2 = @(x) x.^3 - sqrt(x);
  46.  
  47. plot(x1, f(x1), "r", x2, f(x2), "r")
  48.  
  49.  
  50. % Zadanie 2
  51. C = rand(5) * 1000
  52. C(C < 10)
  53. C(C >= 10 & C < 100)
  54. C(C >= 100)
  55.  
  56.  
  57. % Zadanie 3
  58. A = randi(5, 5)
  59. n = size(A, 1);
  60. B = eye(n) | fliplr(eye(n))
  61. sum(A(B))
  62.  
  63.  
  64. % Zadanie 4
  65. function rek(c)
  66.     if (mod(c(end), 2) == 0)
  67.         c(end+1) = 0.5*c(end);
  68.     else
  69.         c(end+1) = 3*c(end)+1;
  70.     endif
  71.     c(end)
  72.     rek(c);
  73. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement