Author Archives: juhan

SICP – cap. 1 – costruire procedure usando lambda – 42

freeuniverser

Sono indaffarato su altre cose ma nei momenti di pausa torno a SICP, come adesso che proseguendo da qui copio qui.

Usare let per creare variabili locali

Another use of lambda is in creating local variables. We often need local variables in our procedures other than those that have been bound as formal parameters. For example, suppose we wish to compute the function

s86

which we could also express as

a = 1 + xy
b = 1 - y
f(x, y) = x * a^2 + y * b + a * b

In writing a procedure to compute f, we would like to include as local variables not only x and y but also the names of intermediate quantities like a and b. One way to accomplish this is to use an auxiliary procedure to bind the local variables:

(define (f x y)
  (define (f-helper a b)
    (+ (* x (square a))
       (* y b)
       (* a b)))
  (f-helper (+ 1 (* x y)) 
            (- 1 y)))

Of course, we could use a lambda expression to specify an anonymous procedure for binding our local variables. The body of f then becomes a single call to that procedure:

(define (f x y)
  ((lambda (a b)
     (+ (* x (square a))
        (* y b)
        (* a b)))
   (+ 1 (* x y))
   (- 1 y)))

This construct is so useful that there is a special form called let to make its use more convenient. Using let, the f procedure could be written as

(define (f x y)
  (let ((a (+ 1 (* x y)))
        (b (- 1 y)))
    (+ (* x (square a))
       (* y b)
       (* a b))))

The general form of a let expression is

(let ((<var1> <exp1>)
      (<var2> <exp2>)
      
      (<varn> <expn>))
   <body>)

which can be thought of as saying

let <var1> have the value <exp1> and
    <var2> have the value <exp2> and
    
    <varn> have the value <expn>
in <body>

The first part of the let expression is a list of name-expression pairs. When the let is evaluated, each name is associated with the value of the corresponding expression. The body of the let is evaluated with these names bound as local variables. The way this happens is that the let expression is interpreted as an alternate syntax for

((lambda (<var1> ...<varn>)
    <body>)
  <exp1>
  ... 
  <expn>)

No new mechanism is required in the interpreter in order to provide local variables. A let expression is simply syntactic sugar for the underlying lambda application.

We can see from this equivalence that the scope of a variable specified by a let expression is the body of the let. This implies that:

  • let allows one to bind variables as locally as possible to where they are to be used. For example, if the value of x is 5, the value of the expression
    (+ (let ((x 3))
    (+ x (* x 10)))
    x)s87
    Here, the x in the body of the let is 3, so the value of the let expression is 33. On the other hand, the x that is the second argument to the outermost + is still 5.
  • The variables’ values are computed outside the let. This matters when the expressions that provide the values for the local variables depend upon variables having the same names as the local variables themselves. For example, if the value of x is 2, the expression
    (let ((x 3)
    (y (+ x 2)))
    (* x y))
    s88
    will have the value 12 because, inside the body of the let, x will be 3 and y will be 4 (which is the outer x plus 2). Basta controllare le parentesi e tutto torna chiaro😉

Sometimes we can use internal definitions to get the same effect as with let. For example, we could have defined the procedure f above as

(define (f x y)
  (define a (+ 1 (* x y)))
  (define b (- 1 y))
  (+ (* x (square a))
     (* y b)
     (* a b)))

We prefer, however, to use let in situations like this and to use internal define only for internal procedures.
Note: Understanding internal definitions well enough to be sure a program means what we intend it to mean requires a more elaborate model of the evaluation process than we have presented in this chapter. The subtleties do not arise with internal definitions of procedures, however. We will return to this issue in section 4.1.6 [lontano futuro chissà…], after we learn more about evaluation.

Uh! pausa che devo assimilare bene😳
:mrgreen:

Visto nel Web – 254

Autunno, malinconia, ritardi (al solito) ma intanto ecco cosa ho visto nel Web.

14440696_1221769107879445_5602749676458004108_n

10 Reasons : Why should we use #Linux?
#:sistemi operativi
::: rewasp1973

Dentro un gigantesco mutamento
#:Web, Internet
::: manteblog

The World’s Most Secure Home Computer Reaches Crowdfunding Goal
#:sicurezza, spionaggio
::: Slashdot

Code.org Disses Wolfram Language, Touts Apple’s Swift Playgrounds
nessuna delle opzioni è quella OK, imho
#:linguaggi di programmazione
::: Slashdot

HP Printers Have A Pre-Programmed Failure Date For Non-HP Ink Cartridges
come Wolkvagen ma al contrario
#:ditte
::: Slashdot

nq160922

Scrivere in un inglese impeccabile? Ci pensa #Ludwig
#:Web, Internet
::: SergioGridelli

The Justice Department is planning a vast expansion of government hacking, and the consequences could be staggering
#:sicurezza, spionaggio
::: WIRED

Decine, e forse centinaia…
#:free open source software
::: Tech Economy

Beau­ti­ful Racket – how to make your own pro­gram­ming lan­guages with Racket—and why
#:lisp e derivati
::: Beau­ti­ful Racket

This describes a way to introduce programming in a wiki
#:programming, codice, snippet
::: wallingf

14457430_10209299063505036_4909964582750580010_n

The rise of dark circuits
#:innovazioni, futuro
::: Daniel Lemire

Know Thy Complexities!
non nuovo ma OK
#:programming, codice, snippet
::: Big-O Cheat Sheet

Your new iPhone’s features include oppression, inequality – and vast profit
#:ditte
::: The Guardian

Un computer in ogni casa
Blaster dr. Alessio ha ragione al 100%, ovviamente😀
#:hardware
::: Grab the Blaster

An Introduction to Stock Market Data Analysis with Python (Part 1)
#:programming, codice, snippet
::: Curtis Miller

13335903_10208325067318071_2703382503129909008_n

Silicon Valley: A Century of Entrepreneurial Innovation
#:storia
::: Computer History Museum

My thoughts on Swift
#:linguaggi di programmazione
::: Daniel Lemire ::: Daniel Lemire

North Korea Has Just 28 Websites
#:Web, Internet
::: Slashdot ::: Slashdot

College Student Got 15 Million Miles By Hacking United Airlines
#:sicurezza, spionaggio
::: Slashdot

Microsoft blocca Linux sui laptop Signature Edition?
#:sistemi operativi
::: lffl ::: Slashdot ::: system76

chsfxudxaaa__sz

Welcome to the C-64 Scene Database
segnalato da medeoTL
#:storia
::: C-64 Scene Database

Functional at Scale
Applying functional programming principles to distributed computing projects
#:programmazione funzionale
::: ACMQ

Nokia Says It Can Deliver Internet 1,000x Faster Than Google Fiber
#:Web, Internet
::: Slashdot

The curious case of the switch statement
#:storia
::: fuzzy notepad

Automating Ad hoc Data Representation Transformations
#:programming, codice, snippet
::: Lambda the Ultimate

ctelilxwiaa5r95

Ruby vs Python, the Definitive FAQ
#:linguaggi di programmazione
::: ThePracticalDev

We need a Snowden for Google and Facebook. Those companies are way more “collect everything” than NSA… and have far less oversight
#:sicurezza, spionaggio
::: thegrugq

Zombie Moore’s Law shows hardware is eating software
citato da tanti; non ho capito granché
#:innovazioni, futuro
::: The Register

97% of the Top Companies Have Leaked Credentials Online
#:sicurezza, spionaggio
::: Slashdot

bunny.gif

Octave – Grafici – V – 69

marco_bruno

Marco Bruno

Sempre sui grafici continuando da qui copio qui.

The errorbar, semilogxerr, semilogyerr, and loglogerr functions produce plots with error bar markers. For example,

x = 0:0.1:10;
y = sin (x);
lerr = 0.1 .* rand (size (x));
uerr = 0.1 .* rand (size (x));
errorbar (x, y, lerr, uerr);

o322

Function File: errorbar (y, ey)
Function File: errorbar (y, ..., fmt)
Function File: errorbar (x, y, ey)
Function File: errorbar (x, y, err, fmt)
Function File: errorbar (x, y, lerr, uerr, fmt)
Function File: errorbar (x, y, ex, ey, fmt)
Function File: errorbar (x, y, lx, ux, ly, uy, fmt)
Function File: errorbar (x1, y1, ..., fmt, xn, yn, ...)
Function File: errorbar (hax, ...)
Function File: h = errorbar (...)

Create a 2-D plot with errorbars.
Many different combinations of arguments are possible. The simplest form is errorbar (y, ey) where the first argument is taken as the set of y coordinates, the second argument ey are the errors around the y values, and the x coordinates are taken to be the indices of the elements (1:numel (y)).
The general form of the function is errorbar (x, y, err1, ..., fmt, ...).
After the x and y arguments there can be 1, 2, or 4 parameters specifying the error values depending on the nature of the error values and the plot format fmt.

  • err (scalar) When the error is a scalar all points share the same error value. The errorbars are symmetric and are drawn from data-err to data+err. The fmt argument determines whether err is in the x-direction, y-direction (default), or both.
  • err (vector or matrix) Each data point has a particular error value. The errorbars are symmetric and are drawn from data(n)-err(n) to data(n)+err(n).
  • lerr, uerr (scalar) The errors have a single low-side value and a single upper-side value. The errorbars are not symmetric and are drawn from data-lerr to data+uerr.
  • lerr, uerr (vector or matrix) Each data point has a low-side error and an upper-side error. The errorbars are not symmetric and are drawn from data(n)-lerr(n) to data(n)+uerr(n).

Any number of data sets (x1,y1, x2,y2, ...) may appear as long as they are separated by a format string fmt.
If y is a matrix, x and the error parameters must also be matrices having the same dimensions. The columns of y are plotted versus the corresponding columns of x and errorbars are taken from the corresponding columns of the error parameters.
If fmt is missing, the yerrorbars ("~") plot style is assumed.
If the fmt argument is supplied then it is interpreted, as in normal plots, to specify the line style, marker, and color. In addition, fmt may include an errorbar style which must precede the ordinary format codes. The following errorbar styles are supported:

  • ~’ Set yerrorbars plot style (default).
  • >’ Set xerrorbars plot style.
  • ~>’ Set xyerrorbars plot style.
  • #~’ Set yboxes plot style.
  • #’ Set xboxes plot style.
  • #~>’ Set xyboxes plot style.

If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a handle to the hggroup object representing the data plot and errorbars.
Note: For compatibility with MATLAB a line is drawn through all data points. However, most scientific errorbar plots are a scatter plot of points with errorbars. To accomplish this, add a marker style to the fmt argument such as “.“. Alternatively, remove the line by modifying the returned graphic handle with set (h, "linestyle", "none").

Non riporto gli esempi che andrebbero completati prima di poterli rappresentare (da fare se dovesse servire).

Function File: semilogxerr (y, ey)
Function File: semilogxerr (y, ..., fmt)
Function File: semilogxerr (x, y, ey)
Function File: semilogxerr (x, y, err, fmt)
Function File: semilogxerr (x, y, lerr, uerr, fmt)
Function File: semilogxerr (x, y, ex, ey, fmt)
Function File: semilogxerr (x, y, lx, ux, ly, uy, fmt)
Function File: semilogxerr (x1, y1, ..., fmt, xn, yn, ...)
Function File: semilogxerr (hax, ...)
Function File: h = semilogxerr (...)

Produce 2-D plots using a logarithmic scale for the x-axis and errorbars at each data point.
Many different combinations of arguments are possible. The most common form is semilogxerr (x, y, ey, fmt) which produces a semi-logarithmic plot of y versus x with errors in the y-scale defined by ey and the plot format defined by fmt.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

Function File: semilogyerr (y, ey)
Function File: semilogyerr (y, ..., fmt)
Function File: semilogyerr (x, y, ey)
Function File: semilogyerr (x, y, err, fmt)
Function File: semilogyerr (x, y, lerr, uerr, fmt)
Function File: semilogyerr (x, y, ex, ey, fmt)
Function File: semilogyerr (x, y, lx, ux, ly, uy, fmt)
Function File: semilogyerr (x1, y1, ..., fmt, xn, yn, ...)
Function File: semilogyerr (hax, ...)
Function File: h = semilogyerr (...)

Produce 2-D plots using a logarithmic scale for the y-axis and errorbars at each data point.
Many different combinations of arguments are possible. The most common form is semilogyerr (x, y, ey, fmt) which produces a semi-logarithmic plot of y versus x with errors in the y-scale defined by ey and the plot format defined by fmt.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

Function File: loglogerr (y, ey)
Function File: loglogerr (y, ..., fmt)
Function File: loglogerr (x, y, ey)
Function File: loglogerr (x, y, err, fmt)
Function File: loglogerr (x, y, lerr, uerr, fmt)
Function File: loglogerr (x, y, ex, ey, fmt)
Function File: loglogerr (x, y, lx, ux, ly, uy, fmt)
Function File: loglogerr (x1, y1, ..., fmt, xn, yn, ...)
Function File: loglogerr (hax, ...)
Function File: h = loglogerr (...)

Produce 2-D plots on a double logarithm axis with errorbars.
Many different combinations of arguments are possible. The most common form is loglogerr (x, y, ey, fmt) which produces a double logarithm plot of y versus x with errors in the y-scale defined by ey and the plot format defined by fmt.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

Finally, the polar function allows you to easily plot data in polar coordinates. However, the display coordinates remain rectangular and linear. For example,

polar (0:0.1:10*pi, 0:0.1:10*pi);

o323

Function File: polar (theta, rho)
Function File: polar (theta, rho, fmt)
Function File: polar (cplx)
Function File: polar (cplx, fmt)
Function File: polar (hax, ...)
Function File: h = polar (...)

Create a 2-D plot from polar coordinates theta and rho.
If a single complex input cplx is given then the real part is used for theta and the imaginary part is used for rho.
The optional argument fmt specifies the line format in the same way as plot.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to the created plot.

Implementation Note: The polar axis is drawn using line and text objects encapsulated in an hggroup. The hggroup properties are linked to the original axes object such that altering an appearance property, for example fontname, will update the polar axis. Two new properties are added to the original axes–rtick, ttick–which replace xtick, ytick. The first is a list of tick locations in the radial (rho) direction; The second is a list of tick locations in the angular (theta) direction specified in degrees, i.e., in the range 0–359.

Function File: pie (x)
Function File: pie (..., explode)
Function File: pie (..., labels)
Function File: pie (hax, ...);
Function File: h = pie (...);

Plot a 2-D pie chart.
When called with a single vector argument, produce a pie chart of the elements in x. The size of the ith slice is the percentage that the element xi represents of the total sum of x: pct = x(i) / sum (x).
The optional input explode is a vector of the same length as x that, if nonzero, “explodes” the slice from the pie chart.
The optional input labels is a cell array of strings of the same length as x specifying the label for each slice.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a list of handles to the patch and text objects generating the plot.
Note: If sum (x) ≤ 1 then the elements of x are interpreted as percentages directly and are not normalized by sum (x). Furthermore, if the sum is less than 1 then there will be a missing slice in the pie plot to represent the missing, unspecified percentage.

x = [8 1 3 5 4 2 1 0];
pie (x);

o324

x =   [8 1 3 5 4 2 1 0];
xpl = [0 1 0 0 1 1 1 0];
pie (x, xpl);

o325

Function File: pie3 (x)
Function File: pie3 (..., explode)
Function File: pie3 (..., labels)
Function File: pie3 (hax, ...);
Function File: h = pie3 (...);

Plot a 3-D pie chart.
Called with a single vector argument, produces a 3-D pie chart of the elements in x. The size of the ith slice is the percentage that the element xi represents of the total sum of x: pct = x(i) / sum (x).
The optional input explode is a vector of the same length as x that, if nonzero, “explodes” the slice from the pie chart.
The optional input labels is a cell array of strings of the same length as x specifying the label for each slice.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a list of graphics handles to the patch, surface, and text objects generating the plot.
Note: If sum (x) ≤ 1 then the elements of x are interpreted as percentages directly and are not normalized by sum (x). Furthermore, if the sum is less than 1 then there will be a missing slice in the pie plot to represent the missing, unspecified percentage.

x = [8 1 3 5 4 2 1 0];
pie3 (x);

o326

x =   [8 1 3 5 4 2 1 0];
xpl = [0 1 0 0 1 1 1 0];
pie3 (x, xpl);

o327

Function File: quiver (u, v)
Function File: quiver (x, y, u, v)
Function File: quiver (..., s)
Function File: quiver (..., style)
Function File: quiver (..., "filled")
Function File: quiver (hax, ...)
Function File: h = quiver (...)

Plot a 2-D vector field with arrows.
Plot the (u, v) components of a vector field in an (x, y) meshgrid. If the grid is uniform then x and y can be specified as vectors.
If x and y are undefined they are assumed to be (1:m, 1:n) where [m, n] = size (u).
The variable s is a scalar defining a scaling factor to use for the arrows of the field relative to the mesh spacing. A value of 0 disables all scaling. The default value is 0.9.
The style to use for the plot can be defined with a line style style of the same format as the plot command. If a marker is specified then markers at the grid points of the vectors are drawn rather than arrows. If the argument "filled" is given then the markers are filled.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to a quiver object. A quiver object regroups the components of the quiver plot (body, arrow, and marker), and allows them to be changed together.

[x, y] = meshgrid (1:2:20);
h = quiver (x, y, sin (2*pi*x/10), sin (2*pi*y/10));
set (h, "maxheadsize", 0.33);

o328

Function File: quiver3 (u, v, w)
Function File: quiver3 (x, y, z, u, v, w)
Function File: quiver3 (..., s)
Function File: quiver3 (..., style)
Function File: quiver3 (..., "filled")
Function File: quiver3 (hax, ...)
Function File: h = quiver3 (...)

Plot a 3-D vector field with arrows.
Plot the (u, v, w) components of a vector field in an (x, y, z) meshgrid. If the grid is uniform then x, y, and z can be specified as vectors.
If x, y, and z are undefined they are assumed to be (1:m, 1:n, 1:p) where [m, n] = size (u) and p = max (size (w)).
The variable s is a scalar defining a scaling factor to use for the arrows of the field relative to the mesh spacing. A value of 0 disables all scaling. The default value is 0.9.
The style to use for the plot can be defined with a line style style of the same format as the plot command. If a marker is specified then markers at the grid points of the vectors are drawn rather than arrows. If the argument "filled" is given then the markers are filled.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to a quiver object. A quiver object regroups the components of the quiver plot (body, arrow, and marker), and allows them to be changed together.

[x, y, z] = peaks (25);
surf (x, y, z);
hold on;
[u, v, w] = surfnorm (x, y, z / 10);
h = quiver3 (x, y, z, u, v, w);
set (h, "maxheadsize", 0.33);

o329

Function File: compass (u, v)
Function File: compass (z)
Function File: compass (..., style)
Function File: compass (hax, ...)
Function File: h = compass (...)

Plot the (u, v) components of a vector field emanating from the origin of a polar plot.
The arrow representing each vector has one end at the origin and the tip at [u(i), v(i)]. If a single complex argument z is given, then u = real (z) and v = imag (z).
The style to use for the plot can be defined with a line style style of the same format as the plot command.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a vector of graphics handles to the line objects representing the drawn vectors.

a = toeplitz ([1;randn(9,1)], [1,randn(1,9)]);
compass (eig (a));

o330

Function File: feather (u, v)
Function File: feather (z)
Function File: feather (..., style)
Function File: feather (hax, ...)
Function File: h = feather (...)

Plot the (u, v) components of a vector field emanating from equidistant points on the x-axis.
If a single complex argument z is given, then u = real (z) and v = imag (z).
The style to use for the plot can be defined with a line style style of the same format as the plot command.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a vector of graphics handles to the line objects representing the drawn vectors.

phi = [0 : 15 : 360] * pi/180;
feather (sin (phi), cos (phi));

o331

Function File: pcolor (x, y, c)
Function File: pcolor (c)
Function File: pcolor (hax, ...)
Function File: h = pcolor (...)

Produce a 2-D density plot.
A pcolor plot draws rectangles with colors from the matrix c over the two-dimensional region represented by the matrices x and y. x and y are the coordinates of the mesh’s vertices and are typically the output of meshgrid. If x and y are vectors, then a typical vertex is (x(j), y(i), c(i,j)). Thus, columns of c correspond to different x values and rows of c correspond to different y values.
The values in c are scaled to span the range of the current colormap. Limits may be placed on the color axis by the command caxis, or by setting the clim property of the parent axis.
The face color of each cell of the mesh is determined by interpolating the values of c for each of the cell’s vertices; Contrast this with imagesc which renders one cell for each element of c.
shading modifies an attribute determining the manner by which the face color of each cell is interpolated from the values of c, and the visibility of the cells’ edges. By default the attribute is "faceted", which renders a single color for each cell’s face with the edge visible.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to the created surface object.

n = 6;
r = (0:n)'/n;
theta = pi*(-n:n)/n;
X = r*cos(theta);
Y = r*sin(theta);
C = r*cos(2*theta);
pcolor(X,Y,C)
axis equal tight

o332

Function File: area (y)
Function File: area (x, y)
Function File: area (..., lvl)
Function File: area (..., prop, val, ...)
Function File: area (hax, ...)
Function File: h = area (...)

Area plot of the columns of y.
This plot shows the contributions of each column value to the row sum. It is functionally similar to plot (x, cumsum (y, 2)), except that the area under the curve is shaded.
If the x argument is omitted it defaults to 1:rows (y). A value lvl can be defined that determines where the base level of the shading under the curve should be defined. The default level is 0.
Additional property/value pairs are passed directly to the underlying patch object.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to the hggroup object comprising the area patch objects. The "BaseValue" property of the hggroup can be used to adjust the level where shading begins.

t = linspace (0, 2*pi, 100)';
y = [sin(t).^2, cos(t).^2];
area (t, y);
legend ("sin^2", "cos^2", "location", "NorthEastOutside");

o333

Function File: fill (x, y, c)
Function File: fill (x1, y1, c1, x2, y2, c2)
Function File: fill (..., prop, val)
Function File: fill (hax, ...)
Function File: h = fill (...)

Create one or more filled 2-D polygons.
The inputs x and y are the coordinates of the polygon vertices. If the inputs are matrices then the rows represent different vertices and each column produces a different polygon. fill will close any open polygons before plotting.
The input c determines the color of the polygon. The simplest form is a single color specification such as a plot format or an RGB-triple. In this case the polygon(s) will have one unique color. If c is a vector or matrix then the color data is first scaled using caxis and then indexed into the current colormap. A row vector will color each polygon (a column from matrices x and y) with a single computed color. A matrix c of the same size as x and y will compute the color of each vertex and then interpolate the face color between the vertices.
Multiple property/value pairs for the underlying patch object may be specified, but they must appear in pairs.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a vector of graphics handles to the created patch objects.

Example: red square

vertices = [0 0
            1 0
            1 1
            0 1];
fill (vertices(:,1), vertices(:,2), "r");
axis ([-0.5 1.5, -0.5 1.5])
axis equal

o334

Function File: comet (y)
Function File: comet (x, y)
Function File: comet (x, y, p)
Function File: comet (hax, ...)

Produce a simple comet style animation along the trajectory provided by the input coordinate vectors (x, y).
If x is not specified it defaults to the indices of y.
The speed of the comet may be controlled by p, which represents the time each point is displayed before moving to the next one. The default for p is 0.1 seconds.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

t = 0:.01:2*pi;
x = cos(2*t).*(cos(t).^2);
y = sin(2*t).*(sin(t).^2);
comet(x,y);

o335

Function File: comet3 (z)
Function File: comet3 (x, y, z)
Function File: comet3 (x, y, z, p)
Function File: comet3 (hax, ...)

Produce a simple comet style animation along the trajectory provided by the input coordinate vectors (x, y, z).
If only z is specified then x, y default to the indices of z.
The speed of the comet may be controlled by p, which represents the time each point is displayed before moving to the next one. The default for p is 0.1 seconds.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

t = -10*pi:pi/250:10*pi;
x = (cos(2*t).^2).*sin(t);
y = (sin(2*t).^2).*cos(t);
comet3(x,y,t);

o336

Function File: [x, map] = frame2im (f)
Convert movie frame to indexed image.
A movie frame is simply a struct with the fields "cdata" and "colormap".
Support for N-dimensional images or movies is given when f is a struct array. In such cases, x will be a MxNx1xK or MxNx3xK for indexed and RGB movies respectively, with each frame concatenated along the 4th dimension.
Non oso immaginare😳

Function File: im2frame (rgb)
Function File: im2frame (x, map)

Convert image to movie frame.
A movie frame is simply a struct with the fields "cdata" and "colormap".
Support for N-dimensional images is given when each image projection, matrix sizes of MxN and MxNx3 for RGB images, is concatenated along the fourth dimension. In such cases, the returned value is a struct array.

Pfieeewww😀 Servono tutte? No😀
:mrgreen:

Octave – Grafici – IV – 68

wiley-2

Continuo con i grafici, sono qui.

Function File: scatter (x, y)
Function File: scatter (x, y, s)
Function File: scatter (x, y, s, c)
Function File: scatter (..., style)
Function File: scatter (..., "filled")
Function File: scatter (..., prop, val, ...)
Function File: scatter (hax, ...)
Function File: h = scatter (...)

Draw a 2-D scatter plot.
A marker is plotted at each point defined by the coordinates in the vectors x and y.
The size of the markers is determined by s, which can be a scalar or a vector of the same length as x and y. If s is not given, or is an empty matrix, then a default value of 8 points is used.
The color of the markers is determined by c, which can be a string defining a fixed color; a 3-element vector giving the red, green, and blue components of the color; a vector of the same length as x that gives a scaled index into the current colormap; or an Nx3 matrix defining the RGB color of each marker individually.
The marker to use can be changed with the style argument, that is a string defining a marker in the same manner as the plot command. If no marker is specified it defaults to "o" or circles. If the argument "filled" is given then the markers are filled.
Additional property/value pairs are passed directly to the underlying patch object.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to the created patch object.

x = randn (100, 1);
y = randn (100, 1);
scatter (x, y, [], sqrt (x.^2 + y.^2), "filled");

o314

Function File: plotmatrix (x, y)
Function File: plotmatrix (x)
Function File: plotmatrix (..., style)
Function File: plotmatrix (hax, ...)
Function File: [h, ax, bigax, p, pax] = plotmatrix (...)

Scatter plot of the columns of one matrix against another.
Given the arguments x and y that have a matching number of rows, plotmatrix plots a set of axes corresponding to plot (x(:, i), y(:, j)). When called with a single argument x this is equivalent to plotmatrix (x, x) except that the diagonal of the set of axes will be replaced with the histogram hist (x(:, i)).
The marker to use can be changed with the style argument, that is a string defining a marker in the same manner as the plot command.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h provides handles to the individual graphics objects in the scatter plots, whereas ax returns the handles to the scatter plot axis objects.
bigax is a hidden axis object that surrounds the other axes, such that the commands xlabel, title, etc., will be associated with this hidden axis.
Finally, p returns the graphics objects associated with the histogram and pax the corresponding axes objects.

plotmatrix (randn (100, 3), "g+")

o315

Function File: pareto (y)
Function File: pareto (y, x)
Function File: pareto (hax, ...)
Function File: h = pareto (...)

Draw a Pareto chart.
A Pareto chart is a bar graph that arranges information in such a way that priorities for process improvement can be established; It organizes and displays information to show the relative importance of data. The chart is similar to the histogram or bar chart, except that the bars are arranged in decreasing magnitude from left to right along the x-axis.
The fundamental idea (Pareto principle) behind the use of Pareto diagrams is that the majority of an effect is due to a small subset of the causes. For quality improvement, the first few contributing causes (leftmost bars as presented on the diagram) to a problem usually account for the majority of the result. Thus, targeting these “major causes” for elimination results in the most cost-effective improvement scheme.
Typically only the magnitude data y is present in which case x is taken to be the range 1 : length (y). If x is given it may be a string array, a cell array of strings, or a numerical vector.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a 2-element vector with a graphics handle for the created bar plot and a second handle for the created line plot.
An example of the use of pareto is

Cheese = {"Cheddar", "Swiss", "Camembert", ...
          "Munster", "Stilton", "Blue"};
Sold = [105, 30, 70, 10, 15, 20];
pareto (Sold, Cheese);

o316

Function File: rose (th)
Function File: rose (th, nbins)
Function File: rose (th, bins)
Function File: rose (hax, ...)
Function File: h = rose (...)
Function File: [thout rout] = rose (...)

Plot an angular histogram.
With one vector argument, th, plot the histogram with 20 angular bins. If th is a matrix then each column of th produces a separate histogram.
If nbins is given and is a scalar, then the histogram is produced with nbin bins. If bins is a vector, then the center of each bin is defined by the values of bins and the number of bins is given by the number of elements in bins.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a vector of graphics handles to the line objects representing each histogram.
If two output arguments are requested then no plot is made and the polar vectors necessary to plot the histogram are returned instead.

[th, r] = rose ([2*randn(1e5,1), pi + 2*randn(1e5,1)]);
polar (th, r);

o317

The contour, contourf and contourc functions produce two-dimensional contour plots from three-dimensional data.

Function File: contour (z)
Function File: contour (z, vn)
Function File: contour (x, y, z)
Function File: contour (x, y, z, vn)
Function File: contour (..., style)
Function File: contour (hax, ...)
Function File: [c, h] = contour (...)

Create a 2-D contour plot.
Plot level curves (contour lines) of the matrix z, using the contour matrix c computed by contourc from the same arguments; see the latter for their interpretation.
The appearance of contour lines can be defined with a line style style in the same manner as plot. Only line style and color are used; Any markers defined by style are ignored.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional output c contains the contour levels in contourc format.
The optional return value h is a graphics handle to the hggroup comprising the contour lines.

x = 0:2;
y = x;
z = x' * y;
contour (x, y, z, 2:3)

o318

Function File: contourf (z)
Function File: contourf (z, vn)
Function File: contourf (x, y, z)
Function File: contourf (x, y, z, vn)
Function File: contourf (..., style)
Function File: contourf (hax, ...)
Function File: [c, h] = contourf (...)

Create a 2-D contour plot with filled intervals.
Plot level curves (contour lines) of the matrix z and fill the region between lines with colors from the current colormap.
The level curves are taken from the contour matrix c computed by contourc for the same arguments; see the latter for their interpretation.
The appearance of contour lines can be defined with a line style style in the same manner as plot. Only line style and color are used; Any markers defined by style are ignored.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional output c contains the contour levels in contourc format.
The optional return value h is a graphics handle to the hggroup comprising the contour lines.
The following example plots filled contours of the peaks function.

[x, y, z] = peaks (50);
contourf (x, y, z, -7:9)

o319

Function File: [c, lev] = contourc (z)
Function File: [c, lev] = contourc (z, vn)
Function File: [c, lev] = contourc (x, y, z)
Function File: [c, lev] = contourc (x, y, z, vn)

Compute contour lines (isolines of constant Z value).
The matrix z contains height values above the rectangular grid determined by x and y. If only a single input z is provided then x is taken to be 1:rows (z) and y is taken to be 1:columns (z).
The optional input vn is either a scalar denoting the number of contour lines to compute or a vector containing the Z values where lines will be computed. When vn is a vector the number of contour lines is numel (vn). However, to compute a single contour line at a given value use vn = [val, val]. If vn is omitted it defaults to 10.
The return value c is a 2xn matrix containing the contour lines in the following format

c = [lev1, x1, x2, ..., levn, x1, x2, ...
     len1, y1, y2, ..., lenn, y1, y2, ...]

in which contour line n has a level (height) of levn and length of lenn.
The optional return value lev is a vector with the Z values of the contour levels.

x = 0:2;
y = x;
z = x' * y;
contourc (x, y, z, 2:3)

o320

Function File: contour3 (z)
Function File: contour3 (z, vn)
Function File: contour3 (x, y, z)
Function File: contour3 (x, y, z, vn)
Function File: contour3 (..., style)
Function File: contour3 (hax, ...)
Function File: [c, h] = contour3 (...)

Create a 3-D contour plot.
contour3 plots level curves (contour lines) of the matrix z at a Z level corresponding to each contour. This is in contrast to contour which plots all of the contour lines at the same Z level and produces a 2-D plot.
The level curves are taken from the contour matrix c computed by contourc for the same arguments; see the latter for their interpretation.
The appearance of contour lines can be defined with a line style style in the same manner as plot. Only line style and color are used; Any markers defined by style are ignored.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional output c are the contour levels in contourc format.
The optional return value h is a graphics handle to the hggroup comprising the contour lines.

contour3 (peaks (19));
colormap cool;
hold on;
surf (peaks (19), "facecolor", "none", "edgecolor", "black");

o321

Pausa😀

:mrgreen:

cit. & loll – 10

Di corsa ce devo festeggiare anch’io (me) il MinistraBeatriceLorenzin day.

flat-f-u2

Si fa tanto parlare di educazione digitale ma spesso manca l’educazione analogica
::: insopportabile

This Fibonacci joke is as bad
::: sigfpe

Probably one of the most readable ones
::: Symbo1ics

Most positive thing I can say about a language
::: jessitron

Ecco dove vanno davvero a finire i #Pokemon catturati … 😃
::: cmnit

crhajqhxgaeq2us

Norman Rockwell’s classic painting, “Free Speech on Twitter”
::: mrsambarlow

RT @Grady_Booch: Code does not die
::: wallingf

Dopo 26 ore di aggiornamento di #windows10 direi che posso dichiarare morto il pc
::: BeppeBeppetti

*3 di 5 persone hanno trovato utile questa recensione*
::: f_126_ck

Half of 2016’s Amazon reviews are “incentivized” & therefore not to be trusted
::: MIT_CSAIL

csppuofxeaashr3

Largest known twin primes discovered: 2996863034895 * 2^1290000 ± 1
::: daveinstpaul

Maybe before curing cancer Microsoft can fix Linkedin spam?
::: ehud

CIA LOL
::: csoghoian

#RTFM
::: eclipsespark

Ted Nelson writing in 1980
::: TomWhitwell

tumblr_inline_od33947jfq1qb25dg_500

Il mio collega Antonio mette il dito nella piaga. Non ci interessa l’innovazione. Ci interessa la retorica dell’innovazione
::: AlfonsoFuggetta

Microsoft loves Lin… uhm… what?
::: pietroalbini

{ } yourselves, #AWKtober is coming
::: climagic

“learning gnu emacs” index …
::: mat_kelcey

when the engineer only reads half of your email about the design
::: Stammy

dancinha.gif

Octave – Grafici – III – 67

paradigm

Continuo con le funzioni per o grafici da qui. Copio qui.

 
Function File: barh (y)
Function File: barh (x, y)
Function File: barh (..., w)
Function File: barh (..., style)
Function File: barh (..., prop, val, ...)
Function File: barh (hax, ...)
Function File: h = barh (..., prop, val, ...)

Produce a horizontal bar graph from two vectors of X-Y data.
If only one argument is given, it is taken as a vector of Y values and the X coordinates are the range 1:numel (y).
The optional input w controls the width of the bars. A value of 1.0 will cause each bar to exactly touch any adjacent bars. The default width is 0.8.
If y is a matrix, then each column of y is taken to be a separate bar graph plotted on the same graph. By default the columns are plotted side-by-side. This behavior can be changed by the style argument which can take the following values: sono gli stessi di bar(), post precedente.
Optional property/value pairs are passed directly to the underlying patch objects.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to the created bar series hggroup. For a description of the use of the bar series, see bar.

o303

produce

o304

Function File: hist (y)
Function File: hist (y, x)
Function File: hist (y, nbins)
Function File: hist (y, x, norm)
Function File: hist (..., prop, val, ...)
Function File: hist (hax, ...)
Function File: [nn, xx] = hist (...)

Produce histogram counts or plots.
With one vector input argument, y, plot a histogram of the values with 10 bins. The range of the histogram bins is determined by the range of the data. With one matrix input argument, y, plot a histogram where each bin contains a bar per input column.
Given a second vector argument, x, use that as the centers of the bins, with the width of the bins determined from the adjacent values in the vector.
If scalar, the second argument, nbins, defines the number of bins.
If a third argument is provided, the histogram is normalized such that the sum of the bars is equal to norm.
Extreme values are lumped into the first and last bins.
The histogram’s appearance may be modified by specifying property/value pairs. For example the face and edge color may be modified.

hist (randn (1, 100), 25, "facecolor", "r", "edgecolor", "b");

o305

The histogram’s colors also depend upon the current colormap.

hist (rand (10, 3));
colormap (summer ());

o306

If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
With two output arguments, produce the values nn (numbers of elements) and xx (bin centers) such that bar (xx, nn) will plot the histogram.

Function File: stemleaf (x, caption)
Function File: stemleaf (x, caption, stem_sz)
Function File: plotstr = stemleaf (...)

Compute and display a stem and leaf plot of the vector x.
The input x should be a vector of integers. Any non-integer values will be converted to integer by x = fix (x). By default each element of x will be plotted with the last digit of the element as a leaf value and the remaining digits as the stem. For example, 123 will be plotted with the stem ‘12’ and the leaf ‘3’. The second argument, caption, should be a character array which provides a description of the data. It is included as a heading for the output.
The optional input stem_sz sets the width of each stem. The stem width is determined by 10^(stem_sz + 1). The default stem width is 10.
The output of stemleaf is composed of two parts: a “Fenced Letter Display,” followed by the stem-and-leaf plot itself. The Fenced Letter Display is described in Exploratory Data Analysis. Briefly, the entries are as shown:

o307

The stem-and-leaf plot shows on each line the stem value followed by the string made up of the leaf digits. If the stem_sz is not 1 the successive leaf values are separated by “,“.
With no return argument, the plot is immediately displayed. If an output argument is provided, the plot is returned as an array of strings.
The leaf digits are not sorted. If sorted leaf values are desired, use xs = sort (x) before calling stemleaf (xs).
The stem and leaf plot and associated displays are described in: Ch. 3, Exploratory Data Analysis by J. W. Tukey, Addison-Wesley, 1977.

o308

Function File: printd (obj, filename)
Function File: out_file = printd (...)

Convert any object acceptable to disp into the format selected by the suffix of filename.
If the return argument out_file is given, the name of the created file is returned.
This function is intended to facilitate manipulation of the output of functions such as stemleaf.
Non sono riuscito a farla funzionare, ma in fondo non credo di dover usare mai queste cose.

Function File: stairs (y)
Function File: stairs (x, y)
Function File: stairs (..., style)
Function File: stairs (..., prop, val, ...)
Function File: stairs (hax, ...)
Function File: h = stairs (...)
Function File: [xstep, ystep] = stairs (...)

Produce a stairstep plot.
The arguments x and y may be vectors or matrices. If only one argument is given, it is taken as a vector of Y values and the X coordinates are taken to be the indices of the elements.
The style to use for the plot can be defined with a line style style of the same format as the plot command.
Multiple property/value pairs may be specified, but they must appear in pairs.
If the first argument hax is an axis handle, then plot into this axis, rather than the current axis handle returned by gca.
If one output argument is requested, return a graphics handle to the created plot. If two output arguments are specified, the data are generated but not plotted. For example,

stairs (x, y);

and

[xs, ys] = stairs (x, y);
plot (xs, ys);

are equivalent.

Esempio:
y = [0 1 3 5 4 2 1 0];
stairs (y)

o309

Function File: stem (y)
Function File: stem (x, y)
Function File: stem (..., linespec)
Function File: stem (..., "filled")
Function File: stem (..., prop, val, ...)
Function File: stem (hax, ...)
Function File: h = stem (...)

Plot a 2-D stem graph.
If only one argument is given, it is taken as the y-values and the x-coordinates are taken from the indices of the elements.
If y is a matrix, then each column of the matrix is plotted as a separate stem graph. In this case x can either be a vector, the same length as the number of rows in y, or it can be a matrix of the same size as y.
The default color is "b" (blue), the default line style is "-", and the default marker is "o". The line style can be altered by the linespec argument in the same manner as the plot command. If the "filled" argument is present the markers at the top of the stems will be filled in. For example,

x = 1:10;
y = 2*x;
stem (x, y, "r");

plots 10 stems with heights from 2 to 20 in red;

o310

Optional property/value pairs may be specified to control the appearance of the plot.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a handle to a “stem series” hggroup. The single hggroup handle has all of the graphical elements comprising the plot as its children; This allows the properties of multiple graphics objects to be changed by modifying just a single property of the “stem series” hggroup.

For example,

o311

changes the color of the second “stem series” and moves the base line of the first.

o312

Stem Series Properties non le riporto, sono qui.

Function File: stem3 (x, y, z)
Function File: stem3 (..., linespec)
Function File: stem3 (..., "filled")
Function File: stem3 (..., prop, val, ...)
Function File: stem3 (hax, ...)
Function File: h = stem3 (...)

Plot a 3-D stem graph.
Stems are drawn from the height z to the location in the x-y plane determined by x and y. The default color is "b" (blue), the default line style is "-", and the default marker is "o".
The line style can be altered by the linespec argument in the same manner as the plot command. If the “filled” argument is present the markers at the top of the stems will be filled in.
Optional property/value pairs may be specified to control the appearance of the plot.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a handle to the “stem series” hggroup containing the line and marker objects used for the plot.

Example:

theta = 0:0.2:6;
stem3 (cos (theta), sin (theta), theta);

plots 31 stems with heights from 0 to 6 lying on a circle.

o313

Implementation Note: Color definitions with RGB-triples are not valid.

Pausa😀 poi si continuerà
:mrgreen:

(RacketCon)

6rc
Nei giorni scorsi –sabato e domenica scorsi a essere precisi– c’è stata una convention speciale, quella dell’immagine lì sopra.
Con dirette streaming che ho perse tutte😦 ma restano tracce ontehtoobz😀 Per esempio qui si trovano info, slides e altro ancora.

Il Lisp –lo so che mi ripeto– è il linguaggio.
Poi si è evoluto (CL avrebbe davvero bisogno di una nuova release), è nato Scheme.
Poi da Scheme sono derivati altri linguaggi, tanti, mica devo nominarli tutti. Basta uno Racket😀

E i racketeers sono speciali, anche quando twittano, come qui.

polb
Io sono alle prese con tutt’altro (e chissà quando finirà?) ma appena posso ci sono. Una delle presentazioni è stata quella di Matthew Butterick: Beau­ti­ful Racket—how to make your own pro­gram­ming lan­guages with Racket—and why. Da indagare. Poi vi racconto😀

I wish every day could be RacketCon.”

:mrgreen:

Octave – Grafici – II – 66

guitarhomefinal

Continuo da qui, copio qui.

Grafici bidimensionali – 2

Il manuale ha qualche problema, niente di grave ma personalizzo.
The plot function allows you to create simple x-y plots with linear axes. For example,

o288

displays a sine wave shown below. On most systems, this command will open a separate plot window to display the graph.

o289

Function File: plot (y)
Function File: plot (x, y)
Function File: plot (x, y, fmt)
Function File: plot (..., property, value, ...)
Function File: plot (x1, y1, ..., xn, yn)
Function File: plot (hax, ...)
Function File: h = plot (...)

Produce 2-D plots.
Many different combinations of arguments are possible. The simplest form is plot (y) where the argument is taken as the set of y coordinates and the x coordinates are taken to be the range 1:numel (y).
If more than one argument is given, they are interpreted as plot (y, property, value, ...) or plot (x, y, property, value, ...) or plot (x, y, fmt, ...) and so on. Any number of argument sets may appear. The x and y values are interpreted as follows:

  • If a single data argument is supplied, it is taken as the set of y coordinates and the x coordinates are taken to be the indices of the elements, starting with 1.
  • If x and y are scalars, a single point is plotted.
  • squeeze() is applied to arguments with more than two dimensions, but no more than two singleton dimensions.
  • If both arguments are vectors, the elements of y are plotted versus the elements of x.
  • If x is a vector and y is a matrix, then the columns (or rows) of y are plotted versus x. (using whichever combination matches, with columns tried first.)
  • If the x is a matrix and y is a vector, y is plotted versus the columns (or rows) of x. (using whichever combination matches, with columns tried first.)
  • If both arguments are matrices, the columns of y are plotted versus the columns of x. In this case, both matrices must have the same number of rows and columns and no attempt is made to transpose the arguments to make the number of rows match.
    Multiple property-value pairs may be specified, but they must appear in pairs. These arguments are applied to the line objects drawn by plot. Useful properties to modify are "linestyle", "linewidth", "color", "marker", "markersize", "markeredgecolor", "markerfacecolor". See Line Properties.

The fmt format argument can also be used to control the plot style. It is a string composed of four optional parts: ” <linestyle><marker><color><;displayname;>“.  When a marker is specified, but no linestyle, only the markers are plotted. Similarly, if a linestyle is specified, but no marker, then only lines are drawn. If both are specified then lines and markers will be plotted. If no fmt and no property/value pairs are given, then the default plot style is solid lines with no markers and the color determined by the "colororder" property of the current axes.

Format arguments:
non riporto la tabella (lunghissima).

The fmt argument may also be used to assign legend labels. To do so, include the desired label between semicolons after the formatting sequence described above, e.g., "+b;Key Title;". Note that the last semicolon is required and Octave will generate an error if it is left out.

Here are some plot examples:

o290

This command will plot y with red circles, y2 with solid lines, y3 with solid magenta lines, and y4 with points displayed as ‘+’.

o291

e…

o292

This command will plot the data in the variable b, with points displayed as ‘*’ and a marker size of 10.

o293

e ancora…

o294

This will plot the cosine and sine functions and label them accordingly in the legend.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

o295

The optional return value h is a vector of graphics handles to the created line objects.
To save a plot, in one of several image formats such as PostScript or PNG, use the print command. Da vedere il comando print; il grafico può essere salvato via menu File/Save (o Save As).

Function File: plotyy (x1, y1, x2, y2)
Function File: plotyy (..., fun)
Function File: plotyy (..., fun1, fun2)
Function File: plotyy (hax, ...)
Function File: [ax, h1, h2] = plotyy (...)

Plot two sets of data with independent y-axes and a common x-axis.
The arguments x1 and y1 define the arguments for the first plot and x2 and y2 for the second.
By default the arguments are evaluated with feval (@plot, x, y). However the type of plot can be modified with the fun argument, in which case the plots are generated by feval (fun, x, y). fun can be a function handle, an inline function, or a string of a function name.
The function to use for each of the plots can be independently defined with fun1 and fun2.
If the first argument hax is an axes handle, then it defines the principal axis in which to plot the x1 and y1 data.
The return value ax is a vector with the axis handles of the two y-axes. h1 and h2 are handles to the objects generated by the plot commands.

o296

produce

o297

The functions semilogx, semilogy, and loglog are similar to the plot function, but produce plots in which one or both of the axes use log scales.

Function File: semilogx (y)
Function File: semilogx (x, y)
Function File: semilogx (x, y, property, value, ...)
Function File: semilogx (x, y, fmt)
Function File: semilogx (hax, ...)
Function File: h = semilogx (...)

Produce a 2-D plot using a logarithmic scale for the x-axis.
See the documentation of plot for a description of the arguments that semilogx will accept.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to the created plot.

Tutte queste funzioni hanno un equivalente per y; non le riporto.

Function File: loglog (y)
Function File: loglog (x, y)
Function File: loglog (x, y, prop, value, ...)
Function File: loglog (x, y, fmt)
Function File: loglog (hax, ...)
Function File: h = loglog (...)

Produce a 2-D plot using logarithmic scales for both axes.
See the documentation of plot for a description of the arguments that loglog will accept.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to the created plot.

The functions bar, barh, stairs, and stem are useful for displaying discrete data. For example, hist (randn (10000, 1), 30); produces the histogram of 10,000 normally distributed random numbers:

o298

Function File: bar (y)
Function File: bar (x, y)
Function File: bar (..., w)
Function File: bar (..., style)
Function File: bar (..., prop, val, ...)
Function File: bar (hax, ...)
Function File: h = bar (..., prop, val, ...)

Produce a bar graph from two vectors of X-Y data.
If only one argument is given, y, it is taken as a vector of Y values and the X coordinates are the range 1:numel (y).
The optional input w controls the width of the bars. A value of 1.0 will cause each bar to exactly touch any adjacent bars. The default width is 0.8.
If y is a matrix, then each column of y is taken to be a separate bar graph plotted on the same graph. By default the columns are plotted side-by-side. This behavior can be changed by the style argument which can take the following values:

  • "grouped" (default) Side-by-side bars with a gap between bars and centered over the X-coordinate.
  • "stacked" Bars are stacked so that each X value has a single bar composed of multiple segments.
  • "hist" Side-by-side bars with no gap between bars and centered over the X-coordinate.
  • "histc” Side-by-side bars with no gap between bars and left-aligned to the X-coordinate.

Optional property/value pairs are passed directly to the underlying patch objects.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a vector of handles to the created “bar series” hggroups with one handle per column of the variable y. This series makes it possible to change a common element in one bar series object and have the change reflected in the other “bar series”. For example,

h = bar (rand (5, 10));
set (h(1), "basevalue", 0.5);

changes the position on the base of all of the bar series

o299

The following example modifies the face and edge colors using property/value pairs.

bar (randn (1, 100), "facecolor", "r", "edgecolor", "b");

o300

The color of the bars is taken from the figure’s colormap, such that

bar (rand (10, 3));
colormap (summer (64));

will change the colors used for the bars.

o302

The color of bars can also be set manually using the "facecolor" property as shown below.

h = bar (rand (10, 3));
set (h(1), "facecolor", "r")
set (h(2), "facecolor", "g")
set (h(3), "facecolor", "b")

o302

Pausa😀
:mrgreen:

Octave – Grafici – I – 65

cqc

Capitolo nuovo, copio qui, continuando da qui.

Grafici

Il manuale dice “plotting” ma da noi, almeno per qualcuno, genera incomprensione e fraintendimenti. Ah! questa è una delle ragioni di questa lunga serie di post su Octave. Intanto passo qui.

Introduzione
Earlier versions of Octave provided plotting through the use of gnuplot. This capability is still available. But, a newer plotting capability is provided by access to OpenGL. Which plotting system is used is controlled by the graphics_toolkit function. See Graphics Toolkits.

The function call graphics_toolkit ("fltk") selects the FLTK/OpenGL system, and graphics_toolkit ("gnuplot") selects the gnuplot system. The two systems may be used selectively through the use of the graphics_toolkit property of the graphics handle for each figure. This is explained in Graphics Data Structures. Caution: The FLTK toolkit uses single precision variables internally which limits the maximum value that can be displayed to approximately 1038. If your data contains larger values you must use the gnuplot toolkit which supports values up to 10308. O, meglio, cambiare le unità di misura.

Passo qui.

Tipi di grafici
Octave provides simple means to create many different types of two- and three-dimensional plots using high-level functions.
If you need more detailed control, see
Graphics Data Structures and Advanced Plotting.

Ancora avanti, qui.

Grafici bidimensionali
Il sottocapitolo è lunghissimo e come se non bastasse inizia con sottosezioni ce precisano certe condizioni.

Configurazione degli assi
Sono qui.
The axis function may be used to change the axis limits of an existing plot and various other axis properties, such as the aspect ratio and the appearance of tic marks.

Function File: axis ()
Function File: axis ([x_lo x_hi])
Function File: axis ([x_lo x_hi y_lo y_hi])
Function File: axis ([x_lo x_hi y_lo y_hi z_lo z_hi])
Function File: axis (option)
Function File: axis (..., option)
Function File: axis (hax, ...)
Function File: limits = axis ()

Set axis limits and appearance.
The argument limits should be a 2-, 4-, or 6-element vector. The first and second elements specify the lower and upper limits for the x-axis. The third and fourth specify the limits for the y-axis, and the fifth and sixth specify the limits for the z-axis. The special values -Inf and Inf may be used to indicate that the limit should automatically be computed based on the data in the axis.

Without any arguments, axis turns autoscaling on.
With one output argument, limits = axis returns the current axis limits.
The vector argument specifying limits is optional, and additional string arguments may be used to specify various axis properties. For example, axis ([1, 2, 3, 4], "square"); forces a square aspect ratio, and axis ("tic", "labely"); turns tic marks on for all axes and tic mark labels on for the y-axis only.

The following options control the aspect ratio of the axes. Non riporto la tabella, c’è all’URL indicato.

Similarly the axis limits of the colormap can be changed with the caxis function.

Function File: caxis ([cmin cmax])
Function File: caxis ("auto")
Function File: caxis ("manual")
Function File: caxis (hax, ...)
Function File: limits = caxis ()

Query or set color axis limits for plots.
The limits argument should be a 2-element vector specifying the lower and upper limits to assign to the first and last value in the colormap. Data values outside this range are clamped to the first and last colormap entries.
If the "auto" option is given then automatic colormap limits are applied. The automatic algorithm sets cmin to the minimum data value and cmax to the maximum data value. If "manual" is specified then the "climmode" property is set to "manual" and the numeric values in the "clim" property are used for limits.
If the first argument hax is an axes handle, then operate on this axis rather than the current axes returned by gca.
Called without arguments the current color axis limits are returned.

The xlim, ylim, and zlim functions may be used to get or set individual axis limits. Each has the same form.

Function File: xlimits = xlim ()
Function File: xmode = xlim ("mode")
Function File: xlim ([x_lo x_hi])
Function File: xlim ("auto")
Function File: xlim ("manual")
Function File: xlim (hax, ...)

Query or set the limits of the x-axis for the current plot.
Called without arguments xlim returns the x-axis limits of the current plot.
With the input query "mode", return the current x-limit calculation mode which is either "auto" or "manual".
If passed a 2-element vector [x_lo x_hi], the limits of the x-axis are set to these values and the mode is set to "manual".
The current plotting mode can be changed by using either "auto" or "manual" as the argument.
If the first argument hax is an axes handle, then operate on this axis rather than the current axes returned by gca.

Passo qui.

Funzioni per grafici bidimensionali
Octave can plot a function from a function handle, inline function, or string defining the function without the user needing to explicitly create the data to be plotted. The function fplot also generates two-dimensional plots with linear axes using a function name and limits for the range of the x-coordinate instead of the x and y data. For example, fplot (@sin, [-10, 10], 201); produces

o288

Io preferisco fplot (@sin, [0, 2 * pi]);

o289

Function File: fplot (fn, limits)
Function File: fplot (..., tol)
Function File: fplot (..., n)
Function File: fplot (..., fmt)
Function File: [x, y] = fplot (...)

Plot a function fn within the range defined by limits.
fn is a function handle, inline function, or string containing the name of the function to evaluate.
The limits of the plot are of the form [xlo, xhi] or [xlo, xhi, ylo, yhi].
The next three arguments are all optional and any number of them may be given in any order.
tol is the relative tolerance to use for the plot and defaults to 2e-3 (.2%).
n is the minimum number of points to use. When n is specified, the maximum stepsize will be (xhi - xlo) / n. More than n points may still be used in order to meet the relative tolerance requirement.
The fmt argument specifies the linestyle to be used by the plot command.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
With no output arguments the results are immediately plotted. With two output arguments the 2-D plot data is returned. The data can subsequently be plotted manually with plot (x, y).

Example: fplot ("[cos(x), sin(x)]", [0, 2*pi]);

o290

e anche fplot ("[cos(x), sin(x), x / 3]", [0, 2*pi]);

o291

Programming Notes:
fplot works best with continuous functions. Functions with discontinuities are unlikely to plot well. This restriction may be removed in the future.
fplot requires that the function accept and return a vector argument. Consider this when writing user-defined functions and use .*, ./, etc. See the function vectorize for potentially converting inline or anonymous functions to vectorized versions.

Other functions that can create two-dimensional plots directly from a function include ezplot, ezcontour, ezcontourf and ezpolar.

Function File: ezplot (f)
Function File: ezplot (f2v)
Function File: ezplot (fx, fy)
Function File: ezplot (..., dom)
Function File: ezplot (..., n)
Function File: ezplot (hax, ...)
Function File: h = ezplot (...)

Plot the 2-D curve defined by the function f.
The function f may be a string, inline function, or function handle and can have either one or two variables. If f has one variable, then the function is plotted over the domain -2*pi < x < 2*pi with 500 points.
If f2v is a function of two variables then the implicit function f(x,y) = 0 is calculated over the meshed domain -2*pi <= x | y <= 2*pi with 60 points in each dimension.

For example: ezplot (@(x, y) x.^2 - y.^2 - 1)

If two functions are passed as inputs then the parametric function

x = fx (t)
y = fy (t)

is plotted over the domain -2*pi <= t <= 2*pi with 500 points.

o292

If dom is a two element vector, it represents the minimum and maximum values of both x and y, or t for a parametric plot. If dom is a four element vector, then the minimum and maximum values are [xmin xmax ymin ymax].
n is a scalar defining the number of points to use in plotting the function.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a vector of graphics handles to the created line objects.

Function File: ezcontour (f)
Function File: ezcontour (..., dom)
Function File: ezcontour (..., n)
Function File: ezcontour (hax, ...)
Function File: h = ezcontour (...)

Plot the contour lines of a function.
f is a string, inline function, or function handle with two arguments defining the function. By default the plot is over the meshed domain -2*pi <= x | y <= 2*pi with 60 points in each dimension.
If dom is a two element vector, it represents the minimum and maximum values of both x and y. If dom is a four element vector, then the minimum and maximum values are [xmin xmax ymin ymax].
n is a scalar defining the number of points to use in each dimension.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to the created plot.

Example:

o293

procuces

o294

Function File: ezcontourf (f)
Function File: ezcontourf (..., dom)
Function File: ezcontourf (..., n)
Function File: ezcontourf (hax, ...)
Function File: h = ezcontourf (...)

Plot the filled contour lines of a function.
f is a string, inline function, or function handle with two arguments defining the function. By default the plot is over the meshed domain -2*pi <= x | y <= 2*pi with 60 points in each dimension.
If dom is a two element vector, it represents the minimum and maximum values of both x and y. If dom is a four element vector, then the minimum and maximum values are [xmin xmax ymin ymax].
n is a scalar defining the number of points to use in each dimension.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to the created plot.

Example:

f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2);
ezcontourf (f, [-3, 3]);

o295

Function File: ezpolar (f)
Function File: ezpolar (..., dom)
Function File: ezpolar (..., n)
Function File: ezpolar (hax, ...)
Function File: h = ezpolar (...)

Plot a 2-D function in polar coordinates.
The function f is a string, inline function, or function handle with a single argument. The expected form of the function is rho = f(theta). By default the plot is over the domain 0 <= theta <= 2*pi with 500 points.
If dom is a two element vector, it represents the minimum and maximum values of theta.
n is a scalar defining the number of points to use in plotting the function.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to the created plot.

Example: ezpolar (@(t) sin (5/4 * t), [0, 8*pi]);

o296

Avanti qui.

Figure geometriche bidimensionali

Function File: rectangle ()
Function File: rectangle (..., "Position", pos)
Function File: rectangle (..., "Curvature", curv)
Function File: rectangle (..., "EdgeColor", ec)
Function File: rectangle (..., "FaceColor", fc)
Function File: rectangle (hax, ...)
Function File: h = rectangle (...)

Draw a rectangular patch defined by pos and curv.
The variable pos(1:2) defines the lower left-hand corner of the patch and pos(3:4) defines its width and height. By default, the value of pos is [0, 0, 1, 1].
The variable curv defines the curvature of the sides of the rectangle and may be a scalar or two-element vector with values between 0 and 1. A value of 0 represents no curvature of the side, whereas a value of 1 means that the side is entirely curved into the arc of a circle. If curv is a two-element vector, then the first element is the curvature along the x-axis of the patch and the second along y-axis.
If curv is a scalar, it represents the curvature of the shorter of the two sides of the rectangle and the curvature of the other side is defined by min (pos(1:2)) / max (pos(1:2)) * curv.
Additional property/value pairs are passed to the underlying patch command.

If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
The optional return value h is a graphics handle to the created rectangle object.

o297

ottengo

o298

:mrgreen:

AWK, grep e oltre: ack

rr1

Continuo da qui la serie di post su AWK. Cioè dovrei ma oggi esco leggermente fuori tema e parlo di ack di cui ignoravo colpevolmente e completamente l’esistenza. Poi –OK, vi racconto.

I file di visto nel Web li conservo in una directory (cartella) perché non si sa mai. Ma cercare qualcosa lì dentro è come cercare il famoso ago nel pagliaio (ma se ti va bene ti può capitare di trovare la figlia del contadino, dice J.H.Comroe).

Ecco io ero alla ricerca di qualcosa che ricordo benissimo di aver citato –forse– ma esaminare tutti i file non è facile. Anche grep si lamenta, scrive righe non pertinenti, esempio:

sre-7

Eppure… possibile che non ci sia un’opzione giusta? Per fortuna c’è Google. E quando hai un problema c’è una probabilità altissima che lo stesso problema l’abbia già avuto qualcun altro più smart di me. Così sono finito su ack.
Può sostituire grep nel 99% dei casi dice il suo autore Andy Lester.
La home di ack non mi è nuova vuoi vedere che… (da verificare).

Insomma, a farla breve l’ho installato con sudo apt install ack-grep ed ecco

s-re8

OK, da scriptare prima di subito (~/bin/sivw):

#!/bin/bash

ack -iR "$1" ~/lab/OKp/visto\ nel\ web/

abilitarlo con con chmod +x e

s-re9

ricordavo perfettamente (kwasy), e pensa te che

s-re10

aprile 2012, ero giovane allora.

Intanto sono in ritardo, ci sono tante altre novità, per esempio adesso si sta svolgendo #RacketCon, tante cose, da raccontare, per adesso un’immagine

emina-torlak

:mrgreen: