Упражнение 1. Matlab
From Ilianko
% comment A = [ 2 5 3; 5 8 2; 6 2 8] b = [1 2 3] b =b' b = [1; 2; 3] % A.x=b x = A\b A*x format long ans syms a b x (a+b)^20 expand(ans) factor (ans) int(sin(x),x,a,b) F= int(1/(x^24-1)) diff(F,x) simplify(ans) f=simple(ans)
echo on ml_lec1.1 echo o echo off clc A clear A V = [2 3.14 -2.71 1.e-12] x = 2.56 %sin, cos, tan, cot, sinh, ..., asin, ..., log, log10, exp, sqrt, abs, real, imag z = 3 + 4i format short z z2 = 4.5 - 6.7*i z + z2 z2^2 1/Z2 sqrt(z2) ab abs(z) z2\1 1/z2 % pi, i èëè g, Inf, NaN mod(7,2) div(7,2) dv(7,2) dev(7,2) z = complex(a,b) a = 3.5; b = 4.56; z = complex(a,b) % Operacii nad vektori, matrici i polinomi X = 0:pi/200:2*pi; zeros(5,4) Z = zeros(5,4); Z(3,2) = 1 Z(3,3) = 2 ones(5,4) O = ones(5,4) I = eye(7) R = rand(5,4) R = randn(5,4) help randn V = [1 2 3 4 5] length(v) length(V) size(R) R(3,4)=pi; r R tril(R) triu(R) V = [1, 2, 3, 4, 5]; V = diag(V) diag(V) R(3,:) R(:,2) R(:,:) R(3,:)=[] R(:,3)=[] % .*, ./, .\, .^ A = [1 2 3; 4 5 6; 7 8 9]; sin(A) sqrt(A) B = [3 2 1; 6 5 4; 9 8 7]; A .* B A * B A ./ B A / B A \ B sin(A) .^2 + cos(A) .^2 cosh(A) .^2 - si cosh(A) .^2 - sinh(A) .^2 rand(A) % Obrabotka na eksperimentalni danni V = [3 2 7 9 5 1 7 4] max(V) min(V) mean(V) sort(V) sum(V) prod(V) diff(V) x = 0:pi/100:pi; y = sin(x); trapz(x, y) x = 0:pi/1000:pi; trapz(x, y) y = sin(x); trapz(x, y) A = magic(5) sum(A) sum (A,2) sum (daig(A)) sum(diag(A)) sum(diag(rot90(A))) min(A) %Operacii s polinomi p = [5 3 7 1 4 2] p1 = p; p2 = [3 6 2 4 1 7] p = conv(p1,p2) r = [1 2 3 4 5 6 7]; p = poly(r) x = 0.9:0.01:7.1; plot(x, polyval(p, x)), grid on xlabel('x'), ylabel('y'), title('Polynom') x = 0:pi/200:2*pi; plot(x, sin(x), x, cos(x),'LineWidth', 2), grid on legend('sin(x)', 'cos(x)')