Octave – Grafici – IX – 73

p0

Continuo, copio qui.

Annotazioni ai grafici

You can add titles, axis labels, legends, and arbitrary text to an existing plot. For example:

x = -10:0.1:10;
plot (x, sin (x));
title ("sin(x) for x = -10:0.1:10");
xlabel ("x");
ylabel ("sin (x)");
text (pi, 0.7, "arbitrary text");
legend ("sin (x)");

o372

The functions grid and box may also be used to add grid and border lines to the plot. By default, the grid is off and the border lines are on.
Finally, arrows, text and rectangular or elliptic boxes can be added to highlight parts of a plot using the annotation function. Those objects are drawn in an invisible axes, on top of every other axes.

Function File: title (string)
Function File: title (string, prop, val, ...)
Function File: title (hax, ...)
Function File: h = title (...)

Specify the string used as a title for the current axis.
An optional list of property/value pairs can be used to change the appearance of the created title text 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 text object.

Function File: legend (str1, str2, ...)
Function File: legend (matstr)
Function File: legend (cellstr)
Function File: legend (..., "location", pos)
Function File: legend (..., "orientation", orient)
Function File: legend (hax, ...)
Function File: legend (hobjs, ...)
Function File: legend (hax, hobjs, ...)
Function File: legend ("option")
Function File: [hleg, hleg_obj, hplot, labels] = legend (...)

Display a legend for the current axes using the specified strings as labels.
Legend entries may be specified as individual character string arguments, a character array, or a cell array of character strings.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca. If the handles, hobjs, are not specified then the legend’s strings will be associated with the axes’ descendants. legend works on line graphs, bar graphs, etc. A plot must exist before legend is called.
The optional parameter pos specifies the location of the legend as follows:

  • north   center top
  • south   center bottom
  • east   right center
  • west  left center
  • northeast  right top (default)
  • northwest  left top
  • southeast  right bottom
  • southwest  left bottom
  • outside  can be appended to any location string

The optional parameter orient determines if the key elements are placed vertically or horizontally. The allowed values are "vertical" (default) or "horizontal".
The following customizations are available using option:

  • "show" Show legend on the plot
  • "hide" Hide legend on the plot
  • "toggle" Toggles between "hide" and "show"
  • "boxon" Show a box around legend (default)
  • "boxoff" Hide the box around legend
  • "right" Place label text to the right of the keys (default)
  • "left" Place label text to the left of the keys
  • "off" Delete the legend object

The optional output values are

  • hleg The graphics handle of the legend object.
  • hleg_obj Graphics handles to the text and line objects which make up the legend.
  • hplot Graphics handles to the plot objects which were used in making the legend.
  • labels A cell array of strings of the labels in the legend.

The legend label text is either provided in the call to legend or is taken from the DisplayNames property of graphics objects. If no labels or DisplayNames are available, then the label text is simply "data1", "data2", ..., "dataN".
Implementation Note: A legend is implemented as an additional axes object of the current figure with the "tag" set to "legend". Properties of the legend object may be manipulated directly by using set.

Mathlab usa una sintassi diversa; ci sarà da provare😦

Function File: text (x, y, string)
Function File: text (x, y, z, string)
Function File: text (..., prop, val, ...)
Function File: h = text (...)

Create a text object with text string at position x, y, (z) on the current axes.
Multiple locations can be specified if x, y, (z) are vectors. Multiple strings can be specified with a character matrix or a cell array of strings.
Optional property/value pairs may be used to control the appearance of the text.
The optional return value h is a vector of graphics handles to the created text objects.

Function File: xlabel (string)
Function File: xlabel (string, property, val, ...)
Function File: xlabel (hax, ...)
Function File: h = xlabel (...)

Specify the string used to label the x-axis of the current axis.
An optional list of property/value pairs can be used to change the properties of the created text label.
If the first argument hax is an axes handle, then operate on this axis rather than the current axes returned by gca.
The optional return value h is a graphics handle to the created text object.

Function File: clabel (c, h)
Function File: clabel (c, h, v)
Function File: clabel (c, h, "manual")
Function File: clabel (c)
Function File: clabel (..., prop, val, ...)
Function File: h = clabel (...)

Add labels to the contours of a contour plot.
The contour levels are specified by the contour matrix c which is returned by contour, contourc, contourf, and contour3. Contour labels are rotated to match the local line orientation and centered on the line. The position of labels along the contour line is chosen randomly.
If the argument h is a handle to a contour group object, then label this plot rather than the one in the current axes returned by gca.
By default, all contours are labeled. However, the contours to label can be specified by the vector v. If the "manual" argument is given then the contours to label can be selected with the mouse.
Additional property/value pairs that are valid properties of text objects can be given and are passed to the underlying text objects. Moreover, the contour group property "LabelSpacing" is available which determines the spacing between labels on a contour to be specified. The default is 144 points, or 2 inches.
The optional return value h is a vector of graphics handles to the text objects representing each label. The "userdata" property of the text objects contains the numerical value of the contour label.

[c, h] = contour (peaks (), -4 : 6);
clabel (c, h, -4:2:6, "fontsize", 12);

o373

Command: box
Command: box on
Command: box off
Function File: box (hax, ...)

Control display of the axis border.
The argument may be either "on" or "off". If it is omitted, the current box state is toggled.
If the first argument hax is an axes handle, then operate on this axis rather than the current axes returned by gca.

Command: grid
Command: grid on
Command: grid off
Command: grid minor
Command: grid minor on
Command: grid minor off
Function File: grid (hax, ...)

Control the display of plot grid lines.
The function state input may be either "on" or "off". If it is omitted, the current grid state is toggled.
When the first argument is "minor" all subsequent commands modify the minor grid rather than the major grid.
If the first argument hax is an axes handle, then operate on this axis rather than the current axes returned by gca.

x = -10:0.1:10;
y = -10:0.1:10;
plot (floor (x), y);
set (gca, "ygrid", "on");

o374

Command: colorbar
Function File: colorbar (loc)
Function File: colorbar (delete_option)
Function File: colorbar (hcb, ...)
Function File: colorbar (hax, ...)
Function File: colorbar (..., "peer", hax, ...)
Function File: colorbar (..., "location", loc, ...)
Function File: colorbar (..., prop, val, ...)
Function File: h = colorbar (...)

Add a colorbar to the current axes.
A colorbar displays the current colormap along with numerical rulings so that the color scale can be interpreted.
The optional input loc determines the location of the colorbar. Valid values for loc are

  • "EastOutside" Place the colorbar outside the plot to the right. This is the default.
  • "East" Place the colorbar inside the plot to the right.
  • "WestOutside" Place the colorbar outside the plot to the left.
  • "West" Place the colorbar inside the plot to the left.
  • "NorthOutside" Place the colorbar above the plot.
  • "North" Place the colorbar at the top of the plot.
  • "SouthOutside" Place the colorbar under the plot.
  • "South" Place the colorbar at the bottom of the plot.

To remove a colorbar from a plot use any one of the following keywords for the delete_option: "delete", "hide", "off".
If the argument "peer" is given, then the following argument is treated as the axes handle in which to add the colorbar. Alternatively, If the first argument hax is an axes handle, then the colorbar is added to this axis, rather than the current axes returned by gca.
If the first argument hcb is a handle to a colorbar object, then operate on this colorbar directly.
Additional property/value pairs are passed directly to the underlying axes object.
The optional return value h is a graphics handle to the created colorbar object.
Implementation Note: A colorbar is created as an additional axes to the current figure with the "tag" property set to "colorbar". The created axes object has the extra property "location" which controls the positioning of the colorbar.

[x,y] = meshgrid(-2:.2:2);
z = x.*exp(-x.^2 - y.^2);
surf(x,y,z);
pbaspect([2 1 1]);
colorbar("EastOutside");

o375

Function File: annotation (type)
Function File: annotation ("line", x, y)
Function File: annotation ("arrow", x, y)
Function File: annotation ("doublearrow", x, y)
Function File: annotation ("textarrow", x, y)
Function File: annotation ("textbox", pos)
Function File: annotation ("rectangle", pos)
Function File: annotation ("ellipse", pos)
Function File: annotation (..., prop, val)
Function File: annotation (hf, ...)
Function File: h = annotation (...)

Draw annotations to emphasize parts of a figure.
You may build a default annotation by specifying only the type of the annotation.
Otherwise you can select the type of annotation and then set its position using either x and y coordinates for line-based annotations or a position vector pos for others. In either case, coordinates are interpreted using the "units" property of the annotation object. The default is "normalized", which means the lower left hand corner of the figure has coordinates ‘[0 0]’ and the upper right hand corner ‘[1 1]’.
If the first argument hf is a figure handle, then plot into this figure, rather than the current figure returned by gcf.
Further arguments can be provided in the form of prop/val pairs to customize the annotation appearance.
The optional return value h is a graphics handle to the created annotation object. This can be used with the set function to customize an existing annotation object.
All annotation objects share two properties:

  • "units": the units in which coordinates are interpreted.
    Its value may be one of "centimeters" | "characters" | "inches" | "{normalized}" | "pixels" | "points".
  • "position": a four-element vector [x0 y0 width height].
    The vector specifies the coordinates (x0,y0) of the origin of the annotation object, its width, and its height. The width and height may be negative, depending on the orientation of the object.

Valid annotation types and their specific properties are described below:

  • "line" Constructs a line. x and y must be two-element vectors specifying the x and y coordinates of the two ends of the line.
    The line can be customized using "linewidth", "linestyle", and "color" properties the same way as for line objects.
  • "arrow" Construct an arrow. The second point in vectors x and y specifies the arrowhead coordinates.
    Besides line properties, the arrowhead can be customized using "headlength", "headwidth", and "headstyle" properties. Supported values for "headstyle" property are: ["diamond" | "ellipse" | "plain" | "rectangle" | "vback1" | "{vback2}" | "vback3"]
  • "doublearrow" Construct a double arrow. Vectors x and y specify the arrowhead coordinates.
    The line and the arrowhead can be customized as for arrow annotations, but some property names are duplicated: "head1length"/"head2length", "head1width"/"head2width", etc. The index 1 marks the properties of the arrowhead at the first point in x and y coordinates.
  • "textarrow" Construct an arrow with a text label at the opposite end from the arrowhead.
    Use the "string" property to change the text string. The line and the arrowhead can be customized as for arrow annotations, and the text can be customized using the same properties as text graphics objects. Note, however, that some text property names are prefixed with “text” to distinguish them from arrow properties: "textbackgroundcolor", "textcolor", "textedgecolor", "textlinewidth", "textmargin", "textrotation".
  • "textbox" Construct a box with text inside. pos specifies the "position" property of the annotation.
    Use the "string" property to change the text string. You may use "backgroundcolor", "edgecolor", "linestyle", and "linewidth" properties to customize the box background color and edge appearance. A limited set of text objects properties are also available; Besides "font..." properties, you may also use "horizontalalignment" and "verticalalignment" to position the text inside the box.
    Finally, the "fitboxtotext" property controls the actual extent of the box. If "on" (the default) the box limits are fitted to the text extent.
  • "rectangle" Construct a rectangle. pos specifies the “position” property of the annotation.
    You may use "facecolor", "color", "linestyle", and "linewidth" properties to customize the rectangle background color and edge appearance.
  • "ellipse" Construct an ellipse. pos specifies the "position" property of the annotation.

plot(1:10);
x = [0.3 0.5];
y = [0.6 0.5];
annotation("textarrow", x, y, "String", "y = x")
dim = [.6 .4 .3 .3];
str = "Straight Line Plot from 1 to 10";
annotation("textbox", dim, "String", str, "FitBoxToText", "on");
dim = [.4 0.2 0.3 0.3];
str = {"Straight Line Plot","from 1 to 10"};
annotation("textbox", dim, "String", str, "FitBoxToText", "on");

o376

x = linspace(-4,4);
y = x.^3 - 12*x;
plot(x,y)
dim = [.2 .74 .25 .15];
annotation("ellipse",dim)

o377

:mrgreen:

Octave – Grafici – VIII – 72

archi

Copio qui continuando da qui.

Rapporto tra gli assi
For three-dimensional plots the aspect ratio can be set for data with daspect and for the plot box with pbaspect. See Axis Configuration, for controlling the x-, y-, and z-limits for plotting.

Function File: data_aspect_ratio = daspect ()
Function File: daspect (data_aspect_ratio)
Function File: daspect (mode)
Function File: data_aspect_ratio_mode = daspect ("mode")
Function File: daspect (hax, ...)

Query or set the data aspect ratio of the current axes.
The aspect ratio is a normalized 3-element vector representing the span of the x, y, and z-axis limits.
daspect (mode) Set the data aspect ratio mode of the current axes. mode is either "auto" or "manual".
daspect ("mode") Return the data aspect ratio mode of the current axes.
daspect (hax, ...) Operate on the axes in handle hax instead of the current axes.

t = linspace(0,2*pi);
x = cos(t);
y = sin(t);
plot(x,y)
daspect([1 1 1])

o359

t = linspace(0,2*pi);
x = cos(t);
y = sin(t);
plot(x,y)
daspect([1 2 2])

o360

Function File: plot_box_aspect_ratio = pbaspect ( )
Function File: pbaspect (plot_box_aspect_ratio)
Function File: pbaspect (mode)
Function File: plot_box_aspect_ratio_mode = pbaspect ("mode")
Function File: pbaspect (hax, ...)

Query or set the plot box aspect ratio of the current axes.
The aspect ratio is a normalized 3-element vector representing the rendered lengths of the x, y, and z axes.
pbaspect(mode) Set the plot box aspect ratio mode of the current axes. mode is either "auto" or "manual".
pbaspect ("mode") Return the plot box aspect ratio mode of the current axes.
pbaspect (hax, ...) Operate on the axes in handle hax instead of the current axes.

[x,y] = meshgrid(-2:.2:2);
z = x.*exp(-x.^2 - y.^2);
surf(x,y,z)
pbaspect([2 1 1])

o361

Passo qui.

Function File: ezplot3 (fx, fy, fz)
Function File: ezplot3 (..., dom)
Function File: ezplot3 (..., n)
Function File: ezplot3 (hax, ...)
Function File: h = ezplot3 (...)

Plot a parametrically defined curve in three dimensions.
fx, fy, and fz are strings, inline functions, or function handles with one argument defining the function. By default the plot is over the domain 0 <= t <= 2*pi with 500 points.
If dom is a two element vector, it represents the minimum and maximum values of t.
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.

fx = @(t) cos (t);
fy = @(t) sin (t);
fz = @(t) t;
ezplot3 (fx, fy, fz, [0, 10*pi], 100);

o362

Function File: ezmesh (f)
Function File: ezmesh (fx, fy, fz)
Function File: ezmesh (..., dom)
Function File: ezmesh (..., n)
Function File: ezmesh (..., "circ")
Function File: ezmesh (hax, ...)
Function File: h = ezmesh (...)

Plot the mesh defined by 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 three functions are passed, then plot the parametrically defined function [fx (s, t), fy (s, t), fz (s, t)].
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 argument "circ" is given, then the function is plotted over a disk centered on the middle of the domain dom.
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.

Example 1: 2-argument function

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

o363

Example 2: parametrically defined function

fx = @(s,t) cos (s) .* cos (t);
fy = @(s,t) sin (s) .* cos (t);
fz = @(s,t) sin (t);
ezmesh (fx, fy, fz, [-pi, pi, -pi/2, pi/2], 20);

o364

Function File: ezmeshc (f)
Function File: ezmeshc (fx, fy, fz)
Function File: ezmeshc (..., dom)
Function File: ezmeshc (..., n)
Function File: ezmeshc (..., "circ")
Function File: ezmeshc (hax, ...)
Function File: h = ezmeshc (...)

Plot the mesh and contour lines defined by 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 three functions are passed, then plot the parametrically defined function [fx (s, t), fy (s, t), fz (s, t)].
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 argument "circ" is given, then the function is plotted over a disk centered on the middle of the domain dom.
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 mesh plot and a second handle for the created contour plot.

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

o365

Function File: ezsurf (f)
Function File: ezsurf (fx, fy, fz)
Function File: ezsurf (..., dom)
Function File: ezsurf (..., n)
Function File: ezsurf (..., "circ")
Function File: ezsurf (hax, ...)
Function File: h = ezsurf (...)

Plot the surface defined by 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 three functions are passed, then plot the parametrically defined function [fx (s, t), fy (s, t), fz (s, t)].
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 argument "circ" is given, then the function is plotted over a disk centered on the middle of the domain dom.
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.

Example 1: 2-argument function

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

o366

Example 2: parametrically defined function

fx = @(s,t) cos (s) .* cos (t);
fy = @(s,t) sin (s) .* cos (t);
fz = @(s,t) sin (t);
ezsurf (fx, fy, fz, [-pi, pi, -pi/2, pi/2], 20);

o367

Function File: ezsurfc (f)
Function File: ezsurfc (fx, fy, fz)
Function File: ezsurfc (..., dom)
Function File: ezsurfc (..., n)
Function File: ezsurfc (..., "circ")
Function File: ezsurfc (hax, ...)
Function File: h = ezsurfc (...)

Plot the surface and contour lines defined by 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 three functions are passed, then plot the parametrically defined function [fx (s, t), fy (s, t), fz (s, t)].
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 argument "circ" is given, then the function is plotted over a disk centered on the middle of the domain dom.
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 surface plot and a second handle for the created contour plot.

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

o368

Avanti, qui.

Forme geometriche tridimensionali

Command: cylinder
Function File: cylinder (r)
Function File: cylinder (r, n)
Function File: cylinder (hax, ...)
Function File: [x, y, z] = cylinder (...)

Plot a 3-D unit cylinder.
The optional input r is a vector specifying the radius along the unit z-axis. The default is [1 1] indicating radius 1 at Z == 0 and at Z == 1.
The optional input n determines the number of faces around the circumference of the cylinder. The default value is 20.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
If outputs are requested cylinder returns three matrices in meshgrid format, such that surf (x, y, z) generates a unit cylinder.

[x, y, z] = cylinder (10:-1:0, 50);
surf (x, y, z);
title ("a cone");

o369

Function File: sphere ()
Function File: sphere (n)
Function File: sphere (hax, ...)
Function File: [x, y, z] = sphere (...)

Plot a 3-D unit sphere.
The optional input n determines the number of faces around the circumference of the sphere. The default value is 20.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
If outputs are requested sphere returns three matrices in meshgrid format such that surf (x, y, z) generates a unit sphere.

[x, y, z] = sphere (40);
surf (3*x, 3*y, 3*z);
axis equal;
title ("sphere of radius 3");

o370

Function File: ellipsoid (xc, yc, zc, xr, yr, zr, n)
Function File: ellipsoid (..., n)
Function File: ellipsoid (hax, ...)
Function File: [x, y, z] = ellipsoid (...)

Plot a 3-D ellipsoid.
The inputs xc, yc, zc specify the center of the ellipsoid. The inputs xr, yr, zr specify the semi-major axis lengths.
The optional input n determines the number of faces around the circumference of the cylinder. The default value is 20.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
If outputs are requested ellipsoid returns three matrices in meshgrid format, such that surf (x, y, z) generates the ellipsoid.

[x, y, z] = ellipsoid(0,0,0,5.9,3.25,3.25,30);
surf(x, y, z);
axis equal;

o371

:mrgreen:

cit. & loll – 11

Uh! giò😀 presto ecco qua😀

ctacuawxyaaxzs7

Genie: “You have three wishes”
::: catzoup

Stampanti dislessiche, bug nel software o errori di rete?
::: evilripper

Datacenter Scale
dedicata a E & AF😉
::: xkcd

La notizia non è che han rubato 500 milioni di account Yahoo
::: RaffoAR

aliens

“You are reading a book,” the car said. It pulled over and stopped.

prossimamente…
::: MicroSFF

Multitasking
::: Incidental Comics

Ruby vs Python, the Definitive FAQ
::: Hacker Noon

Honestly I don’t know either. I do not speak Sumerian
ma pensa te dov’è andato a prendere il nick!
::: thek3nger

ctvnivswgaakhka

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

Today I realized that #haskell is just a strongly typed fancy version of LISP
::: mgattozzi

im starting to really enjoy programming again
::: sigfig

L’ultima frontiera dei selfie
::: chedisagio

ctxhynguiaaazt

Today I learned
::: juhavantzelfde

AppleAirBag
::: Google+

What is the history of the use of “foo” and “bar” in source code examples?
accuratissimo; ci sono anche i nostri😀
::: stackexchange

Fixing Problems
::: xkcd

Stuart Feldman wrote the first makefile in 1977
::: UnixToolTip

tuffo.gif

Octave – Grafici – VII – 71

rrobot

Continuo da qui a copiare qui, sempre grafici 3D. Ah! abbiamo iniziato le prove vere, prossimamente… forse…😉

Function File: [n] = isonormals (val, v)
Function File: [n] = isonormals (val, p)
Function File: [n] = isonormals (x, y, z, val, v)
Function File: [n] = isonormals (x, y, z, val, p)
Function File: [n] = isonormals (..., "negate")
Function File: isonormals (..., p)

Calculate normals to an isosurface.
If called with one output argument and the first input argument val is a three-dimensional array that contains the data for an isosurface geometry and the second input argument v keeps the vertices of an isosurface then return the normals n in form of a matrix with the same size than v at computed points [x, y, z] = meshgrid (1:l, 1:m, 1:n). The output argument n can be taken to manually set VertexNormals of a patch.
If called with further input arguments x, y and z which are three–dimensional arrays with the same size than val then the volume data is taken at those given points. Instead of the vertices data v a patch handle p can be passed to this function.
If given the string input argument "negate" as last input argument then compute the reverse vector normals of an isosurface geometry.
If no output argument is given then directly redraw the patch that is given by the patch handle p.

For example:

function [] = isofinish (p)
  set (gca, "PlotBoxAspectRatioMode", "manual", ...
            "PlotBoxAspectRatio", [1 1 1]);
  set (p, "VertexNormals", -get (p,"VertexNormals")); # Revert normals
  set (p, "FaceColor", "interp");
  ## set (p, "FaceLighting", "phong");
  ## light ("Position", [1 1 5]); # Available with JHandles
endfunction

N = 15;    # Increase number of vertices in each direction
iso = .4;  # Change isovalue to .1 to display a sphere
lin = linspace (0, 2, N);
[x, y, z] = meshgrid (lin, lin, lin);
c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2);
figure (); # Open another figure window

subplot (2,2,1); view (-38, 20);
[f, v, cdat] = isosurface (x, y, z, c, iso, y);
p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ...
           "FaceColor", "interp", "EdgeColor", "none");
isofinish (p);  # Call user function isofinish

subplot (2,2,2); view (-38, 20);
p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ...
           "FaceColor", "interp", "EdgeColor", "none");
isonormals (x, y, z, c, p); # Directly modify patch
isofinish (p);

subplot (2,2,3); view (-38, 20);
p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ...
           "FaceColor", "interp", "EdgeColor", "none");
n = isonormals (x, y, z, c, v); # Compute normals of isosurface
set (p, "VertexNormals", n);    # Manually set vertex normals
isofinish (p);

subplot (2,2,4); view (-38, 20);
p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ...
           "FaceColor", "interp", "EdgeColor", "none");
isonormals (x, y, z, c, v, "negate"); # Use reverse directly
isofinish (p);

o345

e

o346

Se salvo il file con estensione .m e tento di eseguirlo ottengo errori (e niente grafico). Continuando il discorso di ieri (qui) sembrerebbe che Octave vada comunque eseguito interattivamente, meglio se nella sua GUI.

Function File: [cd] = isocolors (c, v)
Function File: [cd] = isocolors (x, y, z, c, v)
Function File: [cd] = isocolors (x, y, z, r, g, b, v)
Function File: [cd] = isocolors (r, g, b, v)
Function File: [cd] = isocolors (..., p)
Function File: isocolors (...)

Compute isosurface colors.
If called with one output argument and the first input argument c is a three-dimensional array that contains color values and the second input argument v keeps the vertices of a geometry then return a matrix cd with color data information for the geometry at computed points [x, y, z] = meshgrid (1:l, 1:m, 1:n). The output argument cd can be taken to manually set FaceVertexCData of a patch.
If called with further input arguments x, y and z which are three–dimensional arrays of the same size than c then the color data is taken at those given points. Instead of the color data c this function can also be called with RGB values r, g, b. If input argumnets x, y, z are not given then again meshgrid computed values are taken.
Optionally, the patch handle p can be given as the last input argument to all variations of function calls instead of the vertices data v. Finally, if no output argument is given then directly change the colors of a patch that is given by the patch handle p.

function [] = isofinish (p)
  set (gca, "PlotBoxAspectRatioMode", "manual", ...
            "PlotBoxAspectRatio", [1 1 1]);
  set (p, "FaceColor", "interp");
  ## set (p, "FaceLighting", "flat");
  ## light ("Position", [1 1 5]);  # Available with JHandles
endfunction

N = 15;    # Increase number of vertices in each direction
iso = .4;  # Change isovalue to .1 to display a sphere
lin = linspace (0, 2, N);
[x, y, z] = meshgrid (lin, lin, lin);
c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2);
figure (); # Open another figure window

subplot (2,2,1); view (-38, 20);
[f, v] = isosurface (x, y, z, c, iso);
p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
cdat = rand (size (c));       # Compute random patch color data
isocolors (x, y, z, cdat, p); # Directly set colors of patch
isofinish (p);                # Call user function isofinish

subplot (2,2,2); view (-38, 20);
p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
[r, g, b] = meshgrid (lin, 2-lin, 2-lin);
cdat = isocolors (x, y, z, c, v); # Compute color data vertices
set (p, "FaceVertexCData", cdat); # Set color data manually
isofinish (p);

subplot (2,2,3); view (-38, 20);
p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
cdat = isocolors (r, g, b, c, p); # Compute color data patch
set (p, "FaceVertexCData", cdat); # Set color data manually
isofinish (p);

subplot (2,2,4); view (-38, 20);
p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
r = g = b = repmat ([1:N] / N, [N, 1, N]); # Black to white
cdat = isocolors (x, y, z, r, g, b, v);
set (p, "FaceVertexCData", cdat);
isofinish (p);

o347

Function File: shrinkfaces (p, sf)
Function File: nfv = shrinkfaces (p, sf)
Function File: nfv = shrinkfaces (fv, sf)
Function File: nfv = shrinkfaces (f, v, sf)
Function File: [nf, nv] = shrinkfaces (...)

Reduce the size of faces in a patch by the shrink factor sf.
The patch object can be specified by a graphics handle (p), a patch structure (fv) with the fields "faces" and "vertices", or as two separate matrices (f, v) of faces and vertices.
The shrink factor sf is a positive number specifying the percentage of the original area the new face will occupy. If no factor is given the default is 0.3 (a reduction to 30% of the original size). A factor greater than 1.0 will result in the expansion of faces.
Given a patch handle as the first input argument and no output parameters, perform the shrinking of the patch faces in place and redraw the patch.
If called with one output argument, return a structure with fields "faces", "vertices", and "facevertexcdata" containing the data after shrinking. This structure can be used directly as an input argument to the patch function.
Caution:: Performing the shrink operation on faces which are not convex can lead to undesirable results.
Example: a triangulated 3/4 circle and the corresponding shrunken version.

o348

e

o349

Function File: diffuse (sx, sy, sz, lv)
Calculate the diffuse reflection strength of a surface defined by the normal vector elements sx, sy, sz.
The light source location vector lv can be given as a 2-element vector [azimuth, elevation] in degrees or as a 3-element vector [x, y, z].
An optional sixth argument specifies the specular exponent (spread) se. If not given, se defaults to 10.
Niente esempi, complicatissimi e incomprensibili quelli di MathWorks.

Function File: specular (sx, sy, sz, lv, vv)
Function File: specular (sx, sy, sz, lv, vv, se)

Calculate the specular reflection strength of a surface defined by the normal vector elements sx, sy, sz using Phong’s approximation.
The light source location and viewer location vectors are specified using parameters lv and vv respectively. The location vectors can given as 2-element vectors [azimuth, elevation] in degrees or as 3-element vectors [x, y, z].
An optional sixth argument specifies the specular exponent (spread) se. If not given, se defaults to 10.

Function File: [xx, yy] = meshgrid (x, y)
Function File: [xx, yy, zz] = meshgrid (x, y, z)
Function File: [xx, yy] = meshgrid (x)
Function File: [xx, yy, zz] = meshgrid (x)

Given vectors of x and y coordinates, return matrices xx and yy corresponding to a full 2-D grid.
The rows of xx are copies of x, and the columns of yy are copies of y. If y is omitted, then it is assumed to be the same as x.
If the optional z input is given, or zz is requested, then the output will be a full 3-D grid.
meshgrid is most frequently used to produce input for a 2-D or 3-D function that will be plotted. The following example creates a surface plot of the “sombrero” function.

f = @(x,y) sin (sqrt (x.^2 + y.^2)) ./ sqrt (x.^2 + y.^2);
range = linspace (-8, 8, 41);
[X, Y] = meshgrid (range, range);
Z = f (X, Y);
surf (X, Y, Z);

o350

Programming Note: meshgrid is restricted to 2-D or 3-D grid generation. The ndgrid function will generate 1-D through N-D grids. However, the functions are not completely equivalent. If x is a vector of length M and y is a vector of length N, then meshgrid will produce an output grid which is NxM. ndgrid will produce an output which is MxN (transpose) for the same input. Some core functions expect meshgrid input and others expect ndgrid input. Check the documentation for the function in question to determine the proper input format.

Function File: [y1, y2, ..., yn] = ndgrid (x1, x2, ..., xn)
Function File: [y1, y2, ..., yn] = ndgrid (x)

Given n vectors x1, ..., xn, ndgrid returns n arrays of dimension n.
The elements of the i-th output argument contains the elements of the vector xi repeated over all dimensions different from the i-th dimension. Calling ndgrid with only one input argument x is equivalent to calling ndgrid with all n input arguments equal to x:

[y1, y2, ..., yn] = ndgrid (x, ..., x)

Programming Note: ndgrid is very similar to the function meshgrid except that the first two dimensions are transposed in comparison to meshgrid. Some core functions expect meshgrid input and others expect ndgrid input. Check the documentation for the function in question to determine the proper input format.

Function File: plot3 (x, y, z)
Function File: plot3 (x, y, z, prop, value, ...)
Function File: plot3 (x, y, z, fmt)
Function File: plot3 (x, cplx)
Function File: plot3 (cplx)
Function File: plot3 (hax, ...)
Function File: h = plot3 (...)

Produce 3-D plots.
Many different combinations of arguments are possible. The simplest form is plot3 (x, y, z) in which the arguments are taken to be the vertices of the points to be plotted in three dimensions. If all arguments are vectors of the same length, then a single continuous line is drawn. If all arguments are matrices, then each column of is treated as a separate line. No attempt is made to transpose the arguments to make the number of rows match.
If only two arguments are given, as plot3 (x, cplx) the real and imaginary parts of the second argument are used as the y and z coordinates, respectively.
If only one argument is given, as plot3 (cplx) the real and imaginary parts of the argument are used as the y and z values, and they are plotted versus their index.
Arguments may also be given in groups of three as plot3 (x1, y1, z1, x2, y2, z2, ...) in which each set of three arguments is treated as a separate line or set of lines in three dimensions.
To plot multiple one- or two-argument groups, separate each group with an empty format string, as plot3 (x1, c1, "", c2, "", ...)
Multiple property-value pairs may be specified which will affect the line objects drawn by plot3. If the fmt argument is supplied it will format the line objects in the same manner 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.

Dato:

z = [0:0.05:5];

si ha:

plot3 (cos (2*pi*z), sin (2*pi*z), z, ";helix;");

o351

e

plot3 (z, exp (2i*pi*z), ";complex sinusoid;");

o352

Function File: view (azimuth, elevation)
Function File: view ([azimuth elevation])
Function File: view ([x y z])
Function File: view (2)
Function File: view (3)
Function File: view (hax, ...)
Function File: [azimuth, elevation] = view ()

Query or set the viewpoint for the current axes.
The parameters azimuth and elevation can be given as two arguments or as 2-element vector. The viewpoint can also be specified with Cartesian coordinates x, y, and z.
The call view (2) sets the viewpoint to azimuth = 0 and elevation = 90, which is the default for 2-D graphs.
The call view (3) sets the viewpoint to azimuth = -37.5 and elevation = 30, which is the default for 3-D graphs.
If the first argument hax is an axes handle, then operate on this axis rather than the current axes returned by gca.
If no inputs are given, return the current azimuth and elevation.

f = @(x,y) sin (sqrt (x.^2 + y.^2)) ./ sqrt (x.^2 + y.^2);
range = linspace (-8, 8, 41);
Z = f (X, Y);
surf (X, Y, Z);
view (80, 50);

o353

Ho barato, usato il menu del grafico per trovare valori “belli”. Octave deve essere usato interattivamente (come già detto).

Function File: slice (x, y, z, v, sx, sy, sz)
Function File: slice (x, y, z, v, xi, yi, zi)
Function File: slice (v, sx, sy, sz)
Function File: slice (v, xi, yi, zi)
Function File: slice (..., method)
Function File: slice (hax, ...)
Function File: h = slice (...)

Plot slices of 3-D data/scalar fields.
Each element of the 3-dimensional array v represents a scalar value at a location given by the parameters x, y, and z. The parameters x, y, and z are either 3-dimensional arrays of the same size as the array v in the “meshgrid” format or vectors. The parameters xi, etc. respect a similar format to x, etc., and they represent the points at which the array vi is interpolated using interp3. The vectors sx, sy, and sz contain points of orthogonal slices of the respective axes.
If x, y, z are omitted, they are assumed to be x = 1:size (v, 2), y = 1:size (v, 1) and z = 1:size (v, 3).

method is one of:

  • "nearest" Return the nearest neighbor.
  • "linear" Linear interpolation from nearest neighbors.
  • "cubic" Cubic interpolation from four nearest neighbors (not implemented yet).
  • "spline" Cubic spline interpolation—smooth first and second derivatives throughout the curve.

The default method is "linear".

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.

[x, y, z] = meshgrid (linspace (-8, 8, 32));
v = sin (sqrt (x.^2 + y.^2 + z.^2)) ./ (sqrt (x.^2 + y.^2 + z.^2));
slice (x, y, z, v, [], 0, []);

[xi, yi] = meshgrid (linspace (-7, 7));
zi = xi + yi;
slice (x, y, z, v, xi, yi, zi);

o354

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

Draw a ribbon plot for the columns of y vs. x.
The optional parameter width specifies the width of a single ribbon (default is 0.75). If x is omitted, a vector containing the row numbers is assumed (1:rows (Y)).
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 surface objects representing each ribbon.

[x,y] = meshgrid(-3:.5:3,-3:.1:3);
z = peaks(x,y);
ribbon(y,z)

o355

Function File: shading (type)
Function File: shading (hax, type)

Set the shading of patch or surface graphic objects.
Valid arguments for type are

  • "flat" Single colored patches with invisible edges.
  • "faceted" Single colored patches with visible edges.
  • "interp" Color between patch vertices are interpolated and the patch edges are invisible.

If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

Il grafico precedente con shading ("flat"):

o356

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

Draw a 3-D scatter plot.
A marker is plotted at each point defined by the coordinates in the vectors x, y, and z.
The size of the markers is determined by s, which can be a scalar or a vector of the same length as x, y, and z. 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 hggroup object representing the points.

[x, y, z] = peaks (20);
scatter3 (x(:), y(:), z(:), [], z(:), "filled");

o357

Function File: waterfall (x, y, z)
Function File: waterfall (z)
Function File: waterfall (..., c)
Function File: waterfall (..., prop, val, ...)
Function File: waterfall (hax, ...)
Function File: h = waterfall (...)

Plot a 3-D waterfall plot.
A waterfall plot is similar to a meshz plot except only mesh lines for the rows of z (x-values) are shown.
The wireframe mesh is plotted using rectangles. The vertices of the rectangles [x, y] are typically the output of meshgrid. over a 2-D rectangular region in the x-y plane. z determines the height above the plane of each vertex. If only a single z matrix is given, then it is plotted over the meshgrid x = 1:columns (z), y = 1:rows (z). Thus, columns of z correspond to different x values and rows of z correspond to different y values.
The color of the mesh is computed by linearly scaling the z values to fit the range of the current colormap. Use caxis and/or change the colormap to control the appearance.
Optionally the color of the mesh can be specified independently of z by supplying a color matrix, c.
Any property/value pairs are passed directly to the underlying surface 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 surface object.

[X,Y,Z] = peaks(30);
waterfall(X,Y,Z)

o358

Pausa😀 ma mica finisce qui😳
:mrgreen:

Perché i nomi delle variabili devono essere significativi

squirrelNon so se a voi capita mai di svegliarvi nel cuore della notte (le tre meno un quarto), senza un motivo particolare, niente brutti sogni, solo così. E non riuscire più a riaddormentarvi. E per giunta cominciare a lambiccare su un post di sessanta ore prima.
A me è successo questa notte e voglio devo raccontarlo a qualcuno. Tanto il blog lo leggono in pochi e dopo questo incipit diminuiranno ancora. Assay.

La storia è semplicissima, più semplice di come la ricordavo questa notte, questa:

s88

Sì, viene 12. Basta guardare le parentesi.
Anzi no, bisogna vederlo nella GUI, DrRacket:

debug

Uh! vediamo se ho capito per davvero: rinomino la x globale xg e quella locale xl, ottengo:

(define xg 2)
(let ((xl 3)
      (y (+ xg 2)))
  (* xl y))

sp

OK, così è chiaro (spero).
Ma mi resta un dubbio: è solo per rimarcare bene-bene la distinzione tra le variabili locali introdotte da let e quelle esterne o è una delle domande da fare all’esame allo studente rompipalle, dicendogli “l’abbiamo fatto anche a lezione, anzi c’è nel sillabario” (loro lo chiamano così).

ac
Quando ero piccolo agli esami di idraulica (tre se ricordo bene) andava di moda quello in figura (spoiler: Bernoulli, sempre lui).

Dubbio: chissà quanti punti ho perso con questo post? Ma posso ssmettere quando voglio. Probabilmente. Forse…😳

:mrgreen:

Octave – salvare un grafico

lambdaman

Un problema riscontrato con Octave –sì, si sta cominciando a usarlo, per adesso prove ma presto…– che per adesso non ha una soluzione ottimale.

Come visto negli ultimi post creare grafici è immediato. Nei casi pratici non si usano funzioni semplici come negli esempi proposti ma vettori di punti derivanti da elaborazioni e elucubrazioni similari ma la sostanza non cambia. Capita però un piccolo inconveniente sia nell’ambiente integrato che nel terminale (come sono solito fare io). Ecco un esempio:

g0

tutto OK. In alternativa si può usare questa variante:

g1

ancora OK! Ma sono scriptabili? cioè posso creare il file pr.o:

tx = ty = linspace (-8, 8, 41)';
[xx, yy] = meshgrid (tx, ty);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
tz = sin (r) ./ r;
mesh (tx, ty, tz);
print "v.png"

da eseguire così:

g2

ecco! warnings. Ma il file viene prodotto, identico a quello della versione interattiva. Non cambia nulla se la riga incriminata viene sostituita da print ("w.png").

Con saveas ottengo:

tx = ty = linspace (-8, 8, 41)';
[xx, yy] = meshgrid (tx, ty);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
tz = sin (r) ./ r;
handle = mesh (tx, ty, tz);
saveas (handle, "x.png")

g3

In ogni caso il grafico viene prodotto e per adesso resta così. Negli esempi si è usato il formato png ma sono ovviamente disponibili tutti quelli usuali. Resta da vedere quanto Octave possa essere usato convenientemente in modo non interattivo, perdendo la possibilità di modificare il grafico prodotto.

:mrgreen:

Octave – Grafici – VI – 70

codiceatlantico_0011

Oggi copio qui continuando da qui.

Grafici tridimensionali

The function mesh produces mesh surface plots. For example,

tx = ty = linspace (-8, 8, 41)';
[xx, yy] = meshgrid (tx, ty);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
tz = sin (r) ./ r;
mesh (tx, ty, tz);

o337

Note the use of the function meshgrid to create matrices of X and Y coordinates to use for plotting the Z data. The ndgrid function is similar to meshgrid, but works for N-dimensional matrices.

The meshc function is similar to mesh, but also produces a plot of contours for the surface.
The plot3 function displays arbitrary three-dimensional data, without requiring it to form a surface. For example,

t = 0:0.1:10*pi;
r = linspace (0, 1, numel (t));
z = linspace (0, 1, numel (t));
plot3 (r.*sin(t), r.*cos(t), z);

o338

Finally, the view function changes the viewpoint for three-dimensional plots.

Function File: mesh (x, y, z)
Function File: mesh (z)
Function File: mesh (..., c)
Function File: mesh (..., prop, val, ...)
Function File: mesh (hax, ...)
Function File: h = mesh (...)

Plot a 3-D wireframe mesh.
The wireframe mesh is plotted using rectangles. The vertices of the rectangles [x, y] are typically the output of meshgrid. over a 2-D rectangular region in the x-y plane. z determines the height above the plane of each vertex. If only a single z matrix is given, then it is plotted over the meshgrid x = 1:columns (z), y = 1:rows (z). Thus, columns of z correspond to different x values and rows of z correspond to different y values.
The color of the mesh is computed by linearly scaling the z values to fit the range of the current colormap. Use caxis and/or change the colormap to control the appearance.
Optionally, the color of the mesh can be specified independently of z by supplying a color matrix, c.
Any property/value pairs are passed directly to the underlying surface 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 surface object.

Function File: meshc (x, y, z)
Function File: meshc (z)
Function File: meshc (..., c)
Function File: meshc (..., prop, val, ...)
Function File: meshc (hax, ...)
Function File: h = meshc (...)

Plot a 3-D wireframe mesh with underlying contour lines.
The wireframe mesh is plotted using rectangles. The vertices of the rectangles [x, y] are typically the output of meshgrid. over a 2-D rectangular region in the x-y plane. z determines the height above the plane of each vertex. If only a single z matrix is given, then it is plotted over the meshgrid x = 1:columns (z), y = 1:rows (z). Thus, columns of z correspond to different x values and rows of z correspond to different y values.
The color of the mesh is computed by linearly scaling the z values to fit the range of the current colormap. Use caxis and/or change the colormap to control the appearance.
Optionally the color of the mesh can be specified independently of z by supplying a color matrix, c.
Any property/value pairs are passed directly to the underlying surface 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 2-element vector with a graphics handle to the created surface object and to the created contour plot.

Function File: meshz (x, y, z)
Function File: meshz (z)
Function File: meshz (..., c)
Function File: meshz (..., prop, val, ...)
Function File: meshz (hax, ...)
Function File: h = meshz (...)

Plot a 3-D wireframe mesh with a surrounding curtain.
The wireframe mesh is plotted using rectangles. The vertices of the rectangles [x, y] are typically the output of meshgrid. over a 2-D rectangular region in the x-y plane. z determines the height above the plane of each vertex. If only a single z matrix is given, then it is plotted over the meshgrid x = 0:columns (z) - 1, y = 0:rows (z) - 1. Thus, columns of z correspond to different x values and rows of z correspond to different y values.
The color of the mesh is computed by linearly scaling the z values to fit the range of the current colormap. Use caxis and/or change the colormap to control the appearance.
Optionally the color of the mesh can be specified independently of z by supplying a color matrix, c.
Any property/value pairs are passed directly to the underlying surface 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 surface object.

Command: hidden
Command: hidden on
Command: hidden off
Function File: mode = hidden (...)

Control mesh hidden line removal.
When called with no argument the hidden line removal state is toggled.
When called with one of the modes "on" or "off" the state is set accordingly.
The optional output argument mode is the current state.
Hidden Line Removal determines what graphic objects behind a mesh plot are visible. The default is for the mesh to be opaque and lines behind the mesh are not visible. If hidden line removal is turned off then objects behind the mesh can be seen through the faces (openings) of the mesh, although the mesh grid lines are still opaque.

tx = ty = linspace (-8, 8, 41)';
[xx, yy] = meshgrid (tx, ty);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
tz = sin (r) ./ r;
mesh (tx, ty, tz);
hidden

o339

Function File: surf (x, y, z)
Function File: surf (z)
Function File: surf (..., c)
Function File: surf (..., prop, val, ...)
Function File: surf (hax, ...)
Function File: h = surf (...)

Plot a 3-D surface mesh.
The surface mesh is plotted using shaded rectangles. The vertices of the rectangles [x, y] are typically the output of meshgrid. over a 2-D rectangular region in the x-y plane. z determines the height above the plane of each vertex. If only a single z matrix is given, then it is plotted over the meshgrid x = 1:columns (z), y = 1:rows (z). Thus, columns of z correspond to different x values and rows of z correspond to different y values.
The color of the surface is computed by linearly scaling the z values to fit the range of the current colormap. Use caxis and/or change the colormap to control the appearance.
Optionally, the color of the surface can be specified independently of z by supplying a color matrix, c.
Any property/value pairs are passed directly to the underlying surface 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 surface object.
Note: The exact appearance of the surface can be controlled with the shading command or by using set to control surface object properties.

[X,Y,Z] = peaks(25);
surf(X,Y,Z);

o340

Function File: surfc (x, y, z)
Function File: surfc (z)
Function File: surfc (..., c)
Function File: surfc (..., prop, val, ...)
Function File: surfc (hax, ...)
Function File: h = surfc (...)

Plot a 3-D surface mesh with underlying contour lines.
The surface mesh is plotted using shaded rectangles. The vertices of the rectangles [x, y] are typically the output of meshgrid. over a 2-D rectangular region in the x-y plane. z determines the height above the plane of each vertex. If only a single z matrix is given, then it is plotted over the meshgrid x = 1:columns (z), y = 1:rows (z). Thus, columns of z correspond to different x values and rows of z correspond to different y values.
The color of the surface is computed by linearly scaling the z values to fit the range of the current colormap. Use caxis and/or change the colormap to control the appearance.
Optionally, the color of the surface can be specified independently of z by supplying a color matrix, c.
Any property/value pairs are passed directly to the underlying surface 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 surface object.
Note: The exact appearance of the surface can be controlled with the shading command or by using set to control surface object properties.

Function File: surfl (z)
Function File: surfl (x, y, z)
Function File: surfl (..., lsrc)
Function File: surfl (x, y, z, lsrc, P)
Function File: surfl (..., "cdata")
Function File: surfl (..., "light")
Function File: surfl (hax, ...)
Function File: h = surfl (...)

Plot a 3-D surface using shading based on various lighting models.
The surface mesh is plotted using shaded rectangles. The vertices of the rectangles [x, y] are typically the output of meshgrid. over a 2-D rectangular region in the x-y plane. z determines the height above the plane of each vertex. If only a single z matrix is given, then it is plotted over the meshgrid x = 1:columns (z), y = 1:rows (z). Thus, columns of z correspond to different x values and rows of z correspond to different y values.
The default lighting mode "cdata", changes the cdata property of the surface object to give the impression of a lighted surface. Warning: The alternative mode "light" mode which creates a light object to illuminate the surface is not implemented (yet).
The light source location can be specified using lsrc. It can be given as a 2-element vector [azimuth, elevation] in degrees, or as a 3-element vector [lx, ly, lz]. The default value is rotated 45 degrees counterclockwise to the current view.
The material properties of the surface can specified using a 4-element vector P = [AM D SP exp] which defaults to p = [0.55 0.6 0.4 10].

"AM" strength of ambient light
"D" strength of diffuse reflection
"SP" strength of specular reflection
"EXP" specular exponent

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.

colormap (bone (64));
surfl (peaks);
shading interp;

o341

Function File: surfnorm (x, y, z)
Function File: surfnorm (z)
Function File: surfnorm (..., prop, val, ...)
Function File: surfnorm (hax, ...)
Function File: [nx, ny, nz] = surfnorm (...)

Find the vectors normal to a meshgridded surface.
If x and y are vectors, then a typical vertex is (x(j), y(i), z(i,j)). Thus, columns of z correspond to different x values and rows of z correspond to different y values. If only a single input z is given then x is taken to be 1:rows (z) and y is 1:columns (z).
If no return arguments are requested, a surface plot with the normal vectors to the surface is plotted.
Any property/value input pairs are assigned to the surface object.
If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.
If output arguments are requested then the components of the normal vectors are returned in nx, ny, and nz and no plot is made.
An example of the use of surfnorm is

surfnorm (peaks (25));

o342

Algorithm: The normal vectors are calculated by taking the cross product of the diagonals of each of the quadrilaterals in the meshgrid to find the normal vectors of the centers of these quadrilaterals. The four nearest normal vectors to the meshgrid points are then averaged to obtain the normal to the surface at the meshgridded points.

Function File: [fv] = isosurface (val, iso)
Function File: [fv] = isosurface (x, y, z, val, iso)
Function File: [fv] = isosurface (..., "noshare", "verbose")
Function File: [fvc] = isosurface (..., col)
Function File: [f, v] = isosurface (x, y, z, val, iso)
Function File: [f, v, c] = isosurface (x, y, z, val, iso, col)
Function File: isosurface (x, y, z, val, iso, col, opt)

Calculate isosurface of 3-D data.
If called with one output argument and the first input argument val is a three-dimensional array that contains the data of an isosurface geometry and the second input argument iso keeps the isovalue as a scalar value then return a structure array fv that contains the fields Faces and Vertices at computed points [x, y, z] = meshgrid (1:l, 1:m, 1:n). The output argument fv can directly be taken as an input argument for the patch function.
If called with further input arguments x, y and z which are three–dimensional arrays with the same size than val then the volume data is taken at those given points.
The string input argument "noshare" is only for compatibility and has no effect. If given the string input argument "verbose" then print messages to the command line interface about the current progress.
If called with the input argument col which is a three-dimensional array of the same size than val then take those values for the interpolation of coloring the isosurface geometry. Add the field FaceVertexCData to the structure array fv.
If called with two or three output arguments then return the information about the faces f, vertices v and color data c as separate arrays instead of a single structure array.
If called with no output argument then directly process the isosurface geometry with the patch command.

[x, y, z] = meshgrid (1:5, 1:5, 1:5);
val = rand (5, 5, 5);
isosurface (x, y, z, val, .5);

will directly draw a random isosurface geometry in a graphics window.

o343

Another example for an isosurface geometry with different additional coloring

N = 15;    # Increase number of vertices in each direction
iso = .4;  # Change isovalue to .1 to display a sphere
lin = linspace (0, 2, N);
[x, y, z] = meshgrid (lin, lin, lin);
c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2);
figure (); # Open another figure window

subplot (2,2,1); view (-38, 20);
[f, v] = isosurface (x, y, z, c, iso);
p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
set (gca, "PlotBoxAspectRatioMode", "manual", ...
          "PlotBoxAspectRatio", [1 1 1]);
# set (p, "FaceColor", "green", "FaceLighting", "phong");
# light ("Position", [1 1 5]); # Available with the JHandles package

subplot (2,2,2); view (-38, 20);
p = patch ("Faces", f, "Vertices", v, "EdgeColor", "blue");
set (gca, "PlotBoxAspectRatioMode", "manual", ...
          "PlotBoxAspectRatio", [1 1 1]);
# set (p, "FaceColor", "none", "FaceLighting", "phong");
# light ("Position", [1 1 5]);

subplot (2,2,3); view (-38, 20);
[f, v, c] = isosurface (x, y, z, c, iso, y);
p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", c, ...
           "FaceColor", "interp", "EdgeColor", "none");
set (gca, "PlotBoxAspectRatioMode", "manual", ...
          "PlotBoxAspectRatio", [1 1 1]);
# set (p, "FaceLighting", "phong");
# light ("Position", [1 1 5]);

subplot (2,2,4); view (-38, 20);
p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", c, ...
           "FaceColor", "interp", "EdgeColor", "blue");
set (gca, "PlotBoxAspectRatioMode", "manual", ...
          "PlotBoxAspectRatio", [1 1 1]);
# set (p, "FaceLighting", "phong");
# light ("Position", [1 1 5]);

o344

Sì, andrebbe studiato (quando servirà, se …).

Pausa😀
:mrgreen:

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). Ne ho parlato anche qui.😉

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: