<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>
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.
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:
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.
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.
Write a program that produces the animation below
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>