Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Grupa czerwona:
- % Zadanie 1
- x1 = -5 : 0.01 : -0.01;
- x2 = 0 : 0.01 : 5;
- f1 = @(x) cos(x.^2);
- f2 = @(x) 1 ./(x+1);
- plot(x1, f(x1), "r", x2, f(x2), "r")
- % Zadanie 2
- C = randi(5, 5)
- C(C != 1)
- % Zadanie 3
- A = randi(5, 5)
- n = size(A, 1);
- B = triu(ones(n)) & fliplr(triu(ones(n)));
- sum(A(B))
- % Zadanie 4
- x(1)=3;
- y(1)=4;
- z(1)=5;
- for n=1:3
- x(n+1)=3*x(n)+2*z(n)+1;
- y(n+1)=3*x(n)+2*z(n)+2;
- z(n+1)=4*x(n)+3*z(n)+2;
- endfor
- for n=1:4
- disp([num2str(x(n)^2)," + ",num2str(y(n)^2)," = ",num2str(z(n)^2)])
- endfor
- Grupa czarna:
- % Zadanie 1
- x1 = -2 : 0.01 : 0;
- x2 = 0 : 0.01 : 2;
- f1 = @(x) sin(x.^5);
- f2 = @(x) x.^3 - sqrt(x);
- plot(x1, f(x1), "r", x2, f(x2), "r")
- % Zadanie 2
- C = rand(5) * 1000
- C(C < 10)
- C(C >= 10 & C < 100)
- C(C >= 100)
- % Zadanie 3
- A = randi(5, 5)
- n = size(A, 1);
- B = eye(n) | fliplr(eye(n))
- sum(A(B))
- % Zadanie 4
- function rek(c)
- if (mod(c(end), 2) == 0)
- c(end+1) = 0.5*c(end);
- else
- c(end+1) = 3*c(end)+1;
- endif
- c(end)
- rek(c);
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement