import numpy as np
x = [1, 2, 3, 4, 5, 6 ]
v = np.array(x)
v
M = np.array([[1,2], [3,4]])
M
type(v), type(M)
v.shape
M.shape
M.size
M.dtype
np.random.rand(5,3)
np.zeros([5,3])
M = np.array([[1,2,3], [4,5,6]])
N = np.array([[1,1,1], [2,2,2]])
print(N)
print(M)
M + N
5*M
M*N
# Mnożenie macierzy
try:
M.dot(N)
except Exception as e:
print('Exception:',e)
# Transpozycja
M.dot(N.T)
v=np.linspace(0,10,21)
v
np.sin(v)
%matplotlib inline
from matplotlib import pyplot as plt
plt.plot(v, np.sin(v))
M = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16]])
M
M[:,2]
M[2,1:3]
M[1:3,2:4]
M[::2,:]
M
M[::2,::2]=0
M