laboratorium 01 py id 261468 Nieznany

background image














SIGNAL PROCESSING

Laboratory #1:

Introduction to Python

and PyLab environment







M. Kociński, P. Strumiłło



Medical Electronics Division

Institute of Electronics






background image



Signal Processing, Biomedical Engineering

M. Kociński, P. Strumiłło, Institute of Electronics, Lodz University of Technology

PURPOSE:


To get acquainted with PyLab environment – declaring variables, arrays and array operations

TASKS:

1. Create your directory on the hard drive, eg. ‘D:/Biomed2012_1’. All the scripts, functions

and files are to be saved in this directory.


2. Start PyLab

3. Change the current working directory of PyLab environment to the directory you created.

(In the main command window, type >>cd D:/Biomed2012_1;)

4. To double-check what is your current directory type >>pwd

5. In PyLab window, declare the following variables (hint: use

www.scipy.org/Tentative_NumPy_Tutorial

and go to ‘Array creation’)

5

a

4

2

1

b

1

0

.

2

c

3

2

2

1

3

4

2

0

1

d

 

1

1

1

j

e




Check type of each of the defined matrices by entering variable_name.ndim, variable_name.shape,
variable_name
.size, variable_name.dtype, variable_name.itemsize,

Type f=zeros_like(d) to create a new array f of the same size and data type as array d but filled with
zeros.
Create array b1 with the same size and values as for array b, but of dtype=’uint8’




background image



Signal Processing, Biomedical Engineering

M. Kociński, P. Strumiłło, Institute of Electronics, Lodz University of Technology

6. Creating vectors:


Type in help(arange)

Type in the commands: g=arange(10); h=arange(10.), i=arange(5,15,3)
Create the following vectors:

101

...

4

3

2

1

j

900

890

...

480

490

500

k

10

...

3

.

0

2

.

0

1

.

0

0

l

500

0

...

0

0

0

0

m

500

1

...

1

1

1

1

n

1

0

0

1

p


Hints: check PyLab help for the following functions:
zeros, ones (to print out the help content type >>help(function_name ) )

7. Type in %whos to see the defined variables in PyLab workspace, use %del command to

delete some of the defined variables. Note that %reset command clears all the variables,
imported modules and defined functions.

8. Create vectors by using the array() commands:

4

2

1

r

,

3

2

7

s

and compute:

r+s, r*s, r**s, dot(r,s)

9. Add, multiply, divide by 2 and compute the power of 2 of vector r by using commands:

r+=2, r*=2, r/=2, r**=2

10. Define array:

55

.

5

44

.

2

78

.

6

4

3

2

999

.

8

56

.

4

1

.

1

t


and compute: t.min(), t.max(),: t.min(axis=0), t.min(axis=1), t.max(axis=0), t.max(axis=1). Consult
help prod, average, std, var, round, clip, ptp, floor, ceil, flipud, pliplr, rot90 and use these
commands for array t

10/13/2012


Wyszukiwarka

Podobne podstrony:
laboratorium 06 py id 261473 Nieznany
laboratorium 05 py id 261472 Nieznany
laboratorium 02 py id 261471 Nieznany
Laboratorium z TM spr1 id 26189 Nieznany
2005 01 podst id 381826 Nieznany (2)
83 Nw 01 Galwanotechnika id 475 Nieznany
Laboratorium 2i3 zswier id 2615 Nieznany
gk 01 wstep id 191745 Nieznany
ProjektKKa 01 Koncepcja id 4003 Nieznany
Cw 01 szablon id 121348 Nieznany
Laboratorium 7 z TM spr2 id 261 Nieznany
Kolokwium nr 2 25 01 13 id 2407 Nieznany
e 03 2015 01 15 id 148697 Nieznany
mat fiz 2007 01 08 id 282355 Nieznany
Namar laboratoria 2012 13 id 31 Nieznany
Laboratorium TSS cw3 id 261862 Nieznany
Laboratorium zadania cz 1 id 26 Nieznany

więcej podobnych podstron