Académique Documents
Professionnel Documents
Culture Documents
Generation of 3 matrices
In [18]: A = np.random.rand(5,5)
B = np.random.rand(5,5)
C = [[0,0,0,1,1],[0,0,0,2,3],[4,5,0,0,0],[4,5,6,7,8],[9,1,2,3,4]]
vt = np.random.rand(5,5)
C = np.array(C)
A = np.array(A)
print A
print B
print A + B
1
2 Operations with matrices
In [19]: # EigenValues from a Matrix
from numpy import linalg as LA
w, v = LA.eig(A)
print w,v
7.045690837196286
2
b = np.array(b)
c = np.dot(a,b)
print c
[[ 9 2 6]
[21 8 15]
[ 9 2 6]]
In [25]: n = np.arange(50);
nn = np.arange(5,-10,-2);
dt = 0.07/50
3
x = np.sin(2 * np.pi * 50 * n * dt)
plt.xlabel('n');
plt.ylabel('x[n]');
plt.title(r'Plot of DT signal $x[n] = 325 \sin(2\pi 50 n \Delta t)$');
plt.stem(n, x);
print nn,n
[ 5 3 1 -1 -3 -5 -7 -9] [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
48 49]
4
In [27]: %matplotlib inline
t = np.linspace(-0.02, 0.05, 1000)
plt.subplot(2,1,1); plt.plot(t, np.exp(2j*np.pi*50*t).real );
plt.xlabel('t');
plt.ylabel('Re x(t)');
plt.title(r'Real part of $x(t)=e^{j 100 \pi t}$');
plt.xlim([-0.02, 0.05]);
plt.subplot(2,1,2); plt.plot(t, np.exp(2j*np.pi*50*t).imag );
plt.xlabel('t');
plt.ylabel('Im x(t)');
plt.title(r'Imaginary part of $x(t)=e^{j 100 \pi t}$');
plt.xlim([-0.02, 0.05]);
plt.show()
5
4 The second part: Load image
In [2]: import skimage.io as io
from skimage.color import rgb2gray
img = io.imread('coqueta.png')
img_grayscale = rgb2gray(img)
show_grayscale = io.imshow(img_grayscale)
io.show()
/Users/jipadilla7/anaconda2/lib/python2.7/site-packages/skimage/io/_plugins/matplotlib_plugin.py
out_of_range_float = (np.issubdtype(image.dtype, np.float) and
6
7