<texit info> author=Roman Putanowicz backgroundtext=http://www.L5.pk.edu.pl/~putanowr/iten.html title=Lab 6: Solving problems; more on plotting showbuttons=off </texit> <texit>\input{/home/prac/putanowr/dokuwiki/data/media/wiki/latex/it_preamb.tex} \setcounter{chapter}{5} </texit> <texit>\begin{comment}</texit> prev | up | next <texit>\end{comment}</texit>

Lab 6 : Solving problems; more on plotting

Description

Recapitulation on sequences summation algorithm. Algorithm for finding the smallest and the greatest element of a sequence. Controlling plots with “axis” command. Plotting polygons. Checking and setting graphics objects properties. Building algorithms for miscellaneous problems.

Skills to be acquired

  • Understanding of the basic algorithms for accumulation of sequence's elements
  • Finding sequence's extreme elements
  • Finding algorithmic solutions for simple problems.
  • Drawing polygons and manipulating properties of graphic objects.

Self study

This lab introduces two basic algorithms for sequences: the one for accumulation of sequence elements, and the one for finding extreme values of sequences elements. By combining these two algorithms it is possible to solve quite a lot students' assessment problems. However in order to tackle real life problems it is necessary to understand and to master other kinds of algorithms. Some of them are the proposal for the self-study:

  • implementation of sequence sorting algorithms, for instance bubble sort, insertion sort.
  • implementation of algorithms for manipulating matrices, for instance: transposing matrix, calculation of trace, finding extreme values in sub-matrices.

Readings

Solved problems

Ex. 6.1.1

In Octave function ginput can be used to query for the position and the code of a mouse or keyboard event:

 [x,y,b] = ginput(1);

In the above line x,y are coordinates of the mouse cursor when the event occurs and b is the key code or mouse button code.

Write a script that will allow a user to define a plygon by clicking in the plot window. Clicking left mouse button should define the vertex position, pressing “c” or “C” should close the polygon and pressing “q” or “Q” should terminate the program.

Solution

Ex. 6.1.2

Given a parametric representation of a 2D curve: \begin{equation*} \mathbf{r}(t)= \begin{cases} x(t) = 2*cos(t)\\ y(t) = 2*sin(t) \end{cases} \quad \text{for} \quad t\in [0,2\pi] \end{equation*} write a script that calculates its length by approximating the curve with N straight segments. The segments' endpoints are calculated by uniform discretization of the parameter range.

Solution.

Ex. 6.1.3

Write a program that produces the animation below
10 squares with rotating color
The size of squares is 1×1 and their centres are located on a circle of radius 3.
Solution.

<texit>\begin{comment}</texit> prev | up | next <texit>\end{comment}</texit>

  • en/teaching/subjects/it/labs/lab6.txt
  • Last modified: 2017/10/02 15:54
  • (external edit)