1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Three-Dimensional Plots (GNU Octave (version 6.2.0))</title>
<meta name="description" content="Three-Dimensional Plots (GNU Octave (version 6.2.0))">
<meta name="keywords" content="Three-Dimensional Plots (GNU Octave (version 6.2.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="High_002dLevel-Plotting.html" rel="up" title="High-Level Plotting">
<link href="Aspect-Ratio.html" rel="next" title="Aspect Ratio">
<link href="Two_002ddimensional-Geometric-Shapes.html" rel="prev" title="Two-dimensional Geometric Shapes">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">
</head>
<body lang="en">
<span id="Three_002dDimensional-Plots"></span><div class="header">
<p>
Next: <a href="Plot-Annotations.html" accesskey="n" rel="next">Plot Annotations</a>, Previous: <a href="Two_002dDimensional-Plots.html" accesskey="p" rel="prev">Two-Dimensional Plots</a>, Up: <a href="High_002dLevel-Plotting.html" accesskey="u" rel="up">High-Level Plotting</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<span id="Three_002dDimensional-Plots-1"></span><h4 class="subsection">15.2.2 Three-Dimensional Plots</h4>
<span id="index-plotting_002c-three_002ddimensional"></span>
<p>The function <code>mesh</code> produces mesh surface plots. For example,
</p>
<div class="example">
<pre class="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);
xlabel ("tx");
ylabel ("ty");
zlabel ("tz");
title ("3-D Sombrero plot");
</pre></div>
<p>produces the familiar “sombrero” plot shown in <a href="#fig_003amesh">Figure 15.5</a>. Note
the use of the function <code>meshgrid</code> to create matrices of X and Y
coordinates to use for plotting the Z data. The <code>ndgrid</code> function
is similar to <code>meshgrid</code>, but works for N-dimensional matrices.
</p>
<div class="float"><span id="fig_003amesh"></span>
<div align="center"><img src="mesh.png" alt="mesh">
</div>
<div class="float-caption"><p><strong>Figure 15.5: </strong>Mesh plot.</p></div></div>
<p>The <code>meshc</code> function is similar to <code>mesh</code>, but also produces a
plot of contours for the surface.
</p>
<p>The <code>plot3</code> function displays arbitrary three-dimensional data,
without requiring it to form a surface. For example,
</p>
<div class="example">
<pre class="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);
xlabel ("r.*sin (t)");
ylabel ("r.*cos (t)");
zlabel ("z");
title ("plot3 display of 3-D helix");
</pre></div>
<p>displays the spiral in three dimensions shown in <a href="#fig_003aplot3">Figure 15.6</a>.
</p>
<div class="float"><span id="fig_003aplot3"></span>
<div align="center"><img src="plot3.png" alt="plot3">
</div>
<div class="float-caption"><p><strong>Figure 15.6: </strong>Three-dimensional spiral.</p></div></div>
<p>Finally, the <code>view</code> function changes the viewpoint for
three-dimensional plots.
</p>
<span id="XREFmesh"></span><dl>
<dt id="index-mesh">: <em></em> <strong>mesh</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>)</em></dt>
<dt id="index-mesh-1">: <em></em> <strong>mesh</strong> <em>(<var>z</var>)</em></dt>
<dt id="index-mesh-2">: <em></em> <strong>mesh</strong> <em>(…, <var>c</var>)</em></dt>
<dt id="index-mesh-3">: <em></em> <strong>mesh</strong> <em>(…, <var>prop</var>, <var>val</var>, …)</em></dt>
<dt id="index-mesh-4">: <em></em> <strong>mesh</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-mesh-5">: <em><var>h</var> =</em> <strong>mesh</strong> <em>(…)</em></dt>
<dd><p>Plot a 3-D wireframe mesh.
</p>
<p>The wireframe mesh is plotted using rectangles. The vertices of the
rectangles [<var>x</var>, <var>y</var>] are typically the output of <code>meshgrid</code>.
over a 2-D rectangular region in the x-y plane. <var>z</var> determines the
height above the plane of each vertex. If only a single <var>z</var> matrix is
given, then it is plotted over the meshgrid
<code><var>x</var> = 1:columns (<var>z</var>), <var>y</var> = 1:rows (<var>z</var>)</code>.
Thus, columns of <var>z</var> correspond to different <var>x</var> values and rows
of <var>z</var> correspond to different <var>y</var> values.
</p>
<p>The color of the mesh is computed by linearly scaling the <var>z</var> values
to fit the range of the current colormap. Use <code>caxis</code> and/or
change the colormap to control the appearance.
</p>
<p>Optionally, the color of the mesh can be specified independently of <var>z</var>
by supplying a color matrix, <var>c</var>.
</p>
<p>Any property/value pairs are passed directly to the underlying surface
object. The full list of properties is documented at
<a href="Surface-Properties.html">Surface Properties</a>.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p>The optional return value <var>h</var> is a graphics handle to the created
surface object.
</p>
<p><strong>See also:</strong> <a href="Three_002ddimensional-Function-Plotting.html#XREFezmesh">ezmesh</a>, <a href="#XREFmeshc">meshc</a>, <a href="#XREFmeshz">meshz</a>, <a href="Plotting-the-Triangulation.html#XREFtrimesh">trimesh</a>, <a href="Two_002dDimensional-Plots.html#XREFcontour">contour</a>, <a href="#XREFsurf">surf</a>, <a href="Graphics-Objects.html#XREFsurface">surface</a>, <a href="#XREFmeshgrid">meshgrid</a>, <a href="#XREFhidden">hidden</a>, <a href="#XREFshading">shading</a>, <a href="Representing-Images.html#XREFcolormap">colormap</a>, <a href="Axis-Configuration.html#XREFcaxis">caxis</a>.
</p></dd></dl>
<span id="XREFmeshc"></span><dl>
<dt id="index-meshc">: <em></em> <strong>meshc</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>)</em></dt>
<dt id="index-meshc-1">: <em></em> <strong>meshc</strong> <em>(<var>z</var>)</em></dt>
<dt id="index-meshc-2">: <em></em> <strong>meshc</strong> <em>(…, <var>c</var>)</em></dt>
<dt id="index-meshc-3">: <em></em> <strong>meshc</strong> <em>(…, <var>prop</var>, <var>val</var>, …)</em></dt>
<dt id="index-meshc-4">: <em></em> <strong>meshc</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-meshc-5">: <em><var>h</var> =</em> <strong>meshc</strong> <em>(…)</em></dt>
<dd><p>Plot a 3-D wireframe mesh with underlying contour lines.
</p>
<p>The wireframe mesh is plotted using rectangles. The vertices of the
rectangles [<var>x</var>, <var>y</var>] are typically the output of <code>meshgrid</code>.
over a 2-D rectangular region in the x-y plane. <var>z</var> determines the
height above the plane of each vertex. If only a single <var>z</var> matrix is
given, then it is plotted over the meshgrid
<code><var>x</var> = 1:columns (<var>z</var>), <var>y</var> = 1:rows (<var>z</var>)</code>.
Thus, columns of <var>z</var> correspond to different <var>x</var> values and rows
of <var>z</var> correspond to different <var>y</var> values.
</p>
<p>The color of the mesh is computed by linearly scaling the <var>z</var> values
to fit the range of the current colormap. Use <code>caxis</code> and/or
change the colormap to control the appearance.
</p>
<p>Optionally the color of the mesh can be specified independently of <var>z</var>
by supplying a color matrix, <var>c</var>.
</p>
<p>Any property/value pairs are passed directly to the underlying surface
object. The full list of properties is documented at
<a href="Surface-Properties.html">Surface Properties</a>.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p>The optional return value <var>h</var> is a 2-element vector with a graphics
handle to the created surface object and to the created contour plot.
</p>
<p><strong>See also:</strong> <a href="Three_002ddimensional-Function-Plotting.html#XREFezmeshc">ezmeshc</a>, <a href="#XREFmesh">mesh</a>, <a href="#XREFmeshz">meshz</a>, <a href="Two_002dDimensional-Plots.html#XREFcontour">contour</a>, <a href="#XREFsurfc">surfc</a>, <a href="Graphics-Objects.html#XREFsurface">surface</a>, <a href="#XREFmeshgrid">meshgrid</a>, <a href="#XREFhidden">hidden</a>, <a href="#XREFshading">shading</a>, <a href="Representing-Images.html#XREFcolormap">colormap</a>, <a href="Axis-Configuration.html#XREFcaxis">caxis</a>.
</p></dd></dl>
<span id="XREFmeshz"></span><dl>
<dt id="index-meshz">: <em></em> <strong>meshz</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>)</em></dt>
<dt id="index-meshz-1">: <em></em> <strong>meshz</strong> <em>(<var>z</var>)</em></dt>
<dt id="index-meshz-2">: <em></em> <strong>meshz</strong> <em>(…, <var>c</var>)</em></dt>
<dt id="index-meshz-3">: <em></em> <strong>meshz</strong> <em>(…, <var>prop</var>, <var>val</var>, …)</em></dt>
<dt id="index-meshz-4">: <em></em> <strong>meshz</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-meshz-5">: <em><var>h</var> =</em> <strong>meshz</strong> <em>(…)</em></dt>
<dd><p>Plot a 3-D wireframe mesh with a surrounding curtain.
</p>
<p>The wireframe mesh is plotted using rectangles. The vertices of the
rectangles [<var>x</var>, <var>y</var>] are typically the output of <code>meshgrid</code>.
over a 2-D rectangular region in the x-y plane. <var>z</var> determines the
height above the plane of each vertex. If only a single <var>z</var> matrix is
given, then it is plotted over the meshgrid
<code><var>x</var> = 1:columns (<var>z</var>), <var>y</var> = 1:rows (<var>z</var>)</code>.
Thus, columns of <var>z</var> correspond to different <var>x</var> values and rows
of <var>z</var> correspond to different <var>y</var> values.
</p>
<p>The color of the mesh is computed by linearly scaling the <var>z</var> values
to fit the range of the current colormap. Use <code>caxis</code> and/or
change the colormap to control the appearance.
</p>
<p>Optionally the color of the mesh can be specified independently of <var>z</var>
by supplying a color matrix, <var>c</var>.
</p>
<p>Any property/value pairs are passed directly to the underlying surface
object. The full list of properties is documented at
<a href="Surface-Properties.html">Surface Properties</a>.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p>The optional return value <var>h</var> is a graphics handle to the created
surface object.
</p>
<p><strong>See also:</strong> <a href="#XREFmesh">mesh</a>, <a href="#XREFmeshc">meshc</a>, <a href="Two_002dDimensional-Plots.html#XREFcontour">contour</a>, <a href="#XREFsurf">surf</a>, <a href="Graphics-Objects.html#XREFsurface">surface</a>, <a href="#XREFwaterfall">waterfall</a>, <a href="#XREFmeshgrid">meshgrid</a>, <a href="#XREFhidden">hidden</a>, <a href="#XREFshading">shading</a>, <a href="Representing-Images.html#XREFcolormap">colormap</a>, <a href="Axis-Configuration.html#XREFcaxis">caxis</a>.
</p></dd></dl>
<span id="XREFhidden"></span><dl>
<dt id="index-hidden">: <em></em> <strong>hidden</strong></dt>
<dt id="index-hidden-1">: <em></em> <strong>hidden</strong> <em>on</em></dt>
<dt id="index-hidden-2">: <em></em> <strong>hidden</strong> <em>off</em></dt>
<dt id="index-hidden-3">: <em><var>mode</var> =</em> <strong>hidden</strong> <em>(…)</em></dt>
<dd><p>Control mesh hidden line removal.
</p>
<p>When called with no argument the hidden line removal state is toggled.
</p>
<p>When called with one of the modes <code>"on"</code> or <code>"off"</code> the state
is set accordingly.
</p>
<p>The optional output argument <var>mode</var> is the current state.
</p>
<p>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.
</p>
<p><strong>See also:</strong> <a href="#XREFmesh">mesh</a>, <a href="#XREFmeshc">meshc</a>, <a href="#XREFmeshz">meshz</a>, <a href="Three_002ddimensional-Function-Plotting.html#XREFezmesh">ezmesh</a>, <a href="Three_002ddimensional-Function-Plotting.html#XREFezmeshc">ezmeshc</a>, <a href="Plotting-the-Triangulation.html#XREFtrimesh">trimesh</a>, <a href="#XREFwaterfall">waterfall</a>.
</p></dd></dl>
<span id="XREFsurf"></span><dl>
<dt id="index-surf">: <em></em> <strong>surf</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>)</em></dt>
<dt id="index-surf-1">: <em></em> <strong>surf</strong> <em>(<var>z</var>)</em></dt>
<dt id="index-surf-2">: <em></em> <strong>surf</strong> <em>(…, <var>c</var>)</em></dt>
<dt id="index-surf-3">: <em></em> <strong>surf</strong> <em>(…, <var>prop</var>, <var>val</var>, …)</em></dt>
<dt id="index-surf-4">: <em></em> <strong>surf</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-surf-5">: <em><var>h</var> =</em> <strong>surf</strong> <em>(…)</em></dt>
<dd><p>Plot a 3-D surface mesh.
</p>
<p>The surface mesh is plotted using shaded rectangles. The vertices of the
rectangles [<var>x</var>, <var>y</var>] are typically the output of <code>meshgrid</code>.
over a 2-D rectangular region in the x-y plane. <var>z</var> determines the
height above the plane of each vertex. If only a single <var>z</var> matrix is
given, then it is plotted over the meshgrid
<code><var>x</var> = 1:columns (<var>z</var>), <var>y</var> = 1:rows (<var>z</var>)</code>.
Thus, columns of <var>z</var> correspond to different <var>x</var> values and rows
of <var>z</var> correspond to different <var>y</var> values.
</p>
<p>The color of the surface is computed by linearly scaling the <var>z</var> values
to fit the range of the current colormap. Use <code>caxis</code> and/or
change the colormap to control the appearance.
</p>
<p>Optionally, the color of the surface can be specified independently of
<var>z</var> by supplying a color matrix, <var>c</var>.
</p>
<p>Any property/value pairs are passed directly to the underlying surface
object. The full list of properties is documented at
<a href="Surface-Properties.html">Surface Properties</a>.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p>The optional return value <var>h</var> is a graphics handle to the created
surface object.
</p>
<p>Note: The exact appearance of the surface can be controlled with the
<code>shading</code> command or by using <code>set</code> to control surface object
properties.
</p>
<p><strong>See also:</strong> <a href="Three_002ddimensional-Function-Plotting.html#XREFezsurf">ezsurf</a>, <a href="#XREFsurfc">surfc</a>, <a href="#XREFsurfl">surfl</a>, <a href="#XREFsurfnorm">surfnorm</a>, <a href="Plotting-the-Triangulation.html#XREFtrisurf">trisurf</a>, <a href="Two_002dDimensional-Plots.html#XREFcontour">contour</a>, <a href="#XREFmesh">mesh</a>, <a href="Graphics-Objects.html#XREFsurface">surface</a>, <a href="#XREFmeshgrid">meshgrid</a>, <a href="#XREFhidden">hidden</a>, <a href="#XREFshading">shading</a>, <a href="Representing-Images.html#XREFcolormap">colormap</a>, <a href="Axis-Configuration.html#XREFcaxis">caxis</a>.
</p></dd></dl>
<span id="XREFsurfc"></span><dl>
<dt id="index-surfc">: <em></em> <strong>surfc</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>)</em></dt>
<dt id="index-surfc-1">: <em></em> <strong>surfc</strong> <em>(<var>z</var>)</em></dt>
<dt id="index-surfc-2">: <em></em> <strong>surfc</strong> <em>(…, <var>c</var>)</em></dt>
<dt id="index-surfc-3">: <em></em> <strong>surfc</strong> <em>(…, <var>prop</var>, <var>val</var>, …)</em></dt>
<dt id="index-surfc-4">: <em></em> <strong>surfc</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-surfc-5">: <em><var>h</var> =</em> <strong>surfc</strong> <em>(…)</em></dt>
<dd><p>Plot a 3-D surface mesh with underlying contour lines.
</p>
<p>The surface mesh is plotted using shaded rectangles. The vertices of the
rectangles [<var>x</var>, <var>y</var>] are typically the output of <code>meshgrid</code>.
over a 2-D rectangular region in the x-y plane. <var>z</var> determines the
height above the plane of each vertex. If only a single <var>z</var> matrix is
given, then it is plotted over the meshgrid
<code><var>x</var> = 1:columns (<var>z</var>), <var>y</var> = 1:rows (<var>z</var>)</code>.
Thus, columns of <var>z</var> correspond to different <var>x</var> values and rows
of <var>z</var> correspond to different <var>y</var> values.
</p>
<p>The color of the surface is computed by linearly scaling the <var>z</var> values
to fit the range of the current colormap. Use <code>caxis</code> and/or
change the colormap to control the appearance.
</p>
<p>Optionally, the color of the surface can be specified independently of
<var>z</var> by supplying a color matrix, <var>c</var>.
</p>
<p>Any property/value pairs are passed directly to the underlying surface
object. The full list of properties is documented at
<a href="Surface-Properties.html">Surface Properties</a>.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p>The optional return value <var>h</var> is a graphics handle to the created
surface object.
</p>
<p>Note: The exact appearance of the surface can be controlled with the
<code>shading</code> command or by using <code>set</code> to control surface object
properties.
</p>
<p><strong>See also:</strong> <a href="Three_002ddimensional-Function-Plotting.html#XREFezsurfc">ezsurfc</a>, <a href="#XREFsurf">surf</a>, <a href="#XREFsurfl">surfl</a>, <a href="#XREFsurfnorm">surfnorm</a>, <a href="Plotting-the-Triangulation.html#XREFtrisurf">trisurf</a>, <a href="Two_002dDimensional-Plots.html#XREFcontour">contour</a>, <a href="#XREFmesh">mesh</a>, <a href="Graphics-Objects.html#XREFsurface">surface</a>, <a href="#XREFmeshgrid">meshgrid</a>, <a href="#XREFhidden">hidden</a>, <a href="#XREFshading">shading</a>, <a href="Representing-Images.html#XREFcolormap">colormap</a>, <a href="Axis-Configuration.html#XREFcaxis">caxis</a>.
</p></dd></dl>
<span id="XREFsurfl"></span><dl>
<dt id="index-surfl">: <em></em> <strong>surfl</strong> <em>(<var>z</var>)</em></dt>
<dt id="index-surfl-1">: <em></em> <strong>surfl</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>)</em></dt>
<dt id="index-surfl-2">: <em></em> <strong>surfl</strong> <em>(…, <var>lsrc</var>)</em></dt>
<dt id="index-surfl-3">: <em></em> <strong>surfl</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>lsrc</var>, <var>P</var>)</em></dt>
<dt id="index-surfl-4">: <em></em> <strong>surfl</strong> <em>(…, "cdata")</em></dt>
<dt id="index-surfl-5">: <em></em> <strong>surfl</strong> <em>(…, "light")</em></dt>
<dt id="index-surfl-6">: <em></em> <strong>surfl</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-surfl-7">: <em><var>h</var> =</em> <strong>surfl</strong> <em>(…)</em></dt>
<dd><p>Plot a 3-D surface using shading based on various lighting models.
</p>
<p>The surface mesh is plotted using shaded rectangles. The vertices of the
rectangles [<var>x</var>, <var>y</var>] are typically the output of <code>meshgrid</code>.
over a 2-D rectangular region in the x-y plane. <var>z</var> determines the
height above the plane of each vertex. If only a single <var>z</var> matrix is
given, then it is plotted over the meshgrid
<code><var>x</var> = 1:columns (<var>z</var>), <var>y</var> = 1:rows (<var>z</var>)</code>.
Thus, columns of <var>z</var> correspond to different <var>x</var> values and rows
of <var>z</var> correspond to different <var>y</var> values.
</p>
<p>The default lighting mode <code>"cdata"</code>, changes the cdata property of the
surface object to give the impression of a lighted surface.
</p>
<p>The alternate mode <code>"light"</code> creates a light object to illuminate the
surface.
</p>
<p>The light source location may be specified using <var>lsrc</var> which can be
a 2-element vector [azimuth, elevation] in degrees, or a 3-element vector
[lx, ly, lz]. The default value is rotated 45 degrees counterclockwise to
the current view.
</p>
<p>The material properties of the surface can specified using a 4-element
vector <var>P</var> = [<var>AM</var> <var>D</var> <var>SP</var> <var>exp</var>] which defaults to
<var>p</var> = [0.55 0.6 0.4 10].
</p>
<dl compact="compact">
<dt><code>"AM"</code> strength of ambient light</dt>
<dt><code>"D"</code> strength of diffuse reflection</dt>
<dt><code>"SP"</code> strength of specular reflection</dt>
<dt><code>"EXP"</code> specular exponent</dt>
</dl>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p>The optional return value <var>h</var> is a graphics handle to the created
surface object.
</p>
<p>Example:
</p>
<div class="example">
<pre class="example">colormap (bone (64));
surfl (peaks);
shading interp;
</pre></div>
<p><strong>See also:</strong> <a href="#XREFdiffuse">diffuse</a>, <a href="#XREFspecular">specular</a>, <a href="#XREFsurf">surf</a>, <a href="#XREFshading">shading</a>, <a href="Representing-Images.html#XREFcolormap">colormap</a>, <a href="Axis-Configuration.html#XREFcaxis">caxis</a>.
</p></dd></dl>
<span id="XREFsurfnorm"></span><dl>
<dt id="index-surfnorm">: <em></em> <strong>surfnorm</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>)</em></dt>
<dt id="index-surfnorm-1">: <em></em> <strong>surfnorm</strong> <em>(<var>z</var>)</em></dt>
<dt id="index-surfnorm-2">: <em></em> <strong>surfnorm</strong> <em>(…, <var>prop</var>, <var>val</var>, …)</em></dt>
<dt id="index-surfnorm-3">: <em></em> <strong>surfnorm</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-surfnorm-4">: <em>[<var>nx</var>, <var>ny</var>, <var>nz</var>] =</em> <strong>surfnorm</strong> <em>(…)</em></dt>
<dd><p>Find the vectors normal to a meshgridded surface.
</p>
<p>If <var>x</var> and <var>y</var> are vectors, then a typical vertex is
(<var>x</var>(j), <var>y</var>(i), <var>z</var>(i,j)). Thus, columns of <var>z</var> correspond
to different <var>x</var> values and rows of <var>z</var> correspond to different
<var>y</var> values. If only a single input <var>z</var> is given then <var>x</var> is
taken to be <code>1:columns (<var>z</var>)</code> and <var>y</var> is
<code>1:rows (<var>z</var>)</code>.
</p>
<p>If no return arguments are requested, a surface plot with the normal
vectors to the surface is plotted.
</p>
<p>Any property/value input pairs are assigned to the surface object. The full
list of properties is documented at <a href="Surface-Properties.html">Surface Properties</a>.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p>If output arguments are requested then the components of the normal
vectors are returned in <var>nx</var>, <var>ny</var>, and <var>nz</var> and no plot is
made. The normal vectors are unnormalized (magnitude != 1). To normalize,
use
</p>
<div class="example">
<pre class="example">len = sqrt (nx.^2 + ny.^2 + nz.^2);
nx ./= len; ny ./= len; nz ./= len;
</pre></div>
<p>An example of the use of <code>surfnorm</code> is
</p>
<div class="example">
<pre class="example">surfnorm (peaks (25));
</pre></div>
<p>Algorithm: The normal vectors are calculated by taking the cross product
of the diagonals of each of the quadrilateral faces in the meshgrid to find
the normal vectors at the center of each face. Next, for each meshgrid
point the four nearest normal vectors are averaged to obtain the final
normal to the surface at the meshgrid point.
</p>
<p>For surface objects, the <code>"VertexNormals"</code> property contains
equivalent information, except possibly near the boundary of the surface
where different interpolation schemes may yield slightly different values.
</p>
<p><strong>See also:</strong> <a href="#XREFisonormals">isonormals</a>, <a href="Two_002dDimensional-Plots.html#XREFquiver3">quiver3</a>, <a href="#XREFsurf">surf</a>, <a href="#XREFmeshgrid">meshgrid</a>.
</p></dd></dl>
<span id="XREFisosurface"></span><dl>
<dt id="index-isosurface">: <em><var>fv</var> =</em> <strong>isosurface</strong> <em>(<var>v</var>, <var>isoval</var>)</em></dt>
<dt id="index-isosurface-1">: <em><var>fv</var> =</em> <strong>isosurface</strong> <em>(<var>v</var>)</em></dt>
<dt id="index-isosurface-2">: <em><var>fv</var> =</em> <strong>isosurface</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>v</var>, <var>isoval</var>)</em></dt>
<dt id="index-isosurface-3">: <em><var>fv</var> =</em> <strong>isosurface</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>v</var>)</em></dt>
<dt id="index-isosurface-4">: <em><var>fvc</var> =</em> <strong>isosurface</strong> <em>(…, <var>col</var>)</em></dt>
<dt id="index-isosurface-5">: <em><var>fv</var> =</em> <strong>isosurface</strong> <em>(…, "noshare")</em></dt>
<dt id="index-isosurface-6">: <em><var>fv</var> =</em> <strong>isosurface</strong> <em>(…, "verbose")</em></dt>
<dt id="index-isosurface-7">: <em>[<var>f</var>, <var>v</var>] =</em> <strong>isosurface</strong> <em>(…)</em></dt>
<dt id="index-isosurface-8">: <em>[<var>f</var>, <var>v</var>, <var>c</var>] =</em> <strong>isosurface</strong> <em>(…)</em></dt>
<dt id="index-isosurface-9">: <em></em> <strong>isosurface</strong> <em>(…)</em></dt>
<dd>
<p>Calculate isosurface of 3-D volume data.
</p>
<p>An isosurface connects points with the same value and is analogous to a
contour plot, but in three dimensions.
</p>
<p>The input argument <var>v</var> is a three-dimensional array that contains data
sampled over a volume.
</p>
<p>The input <var>isoval</var> is a scalar that specifies the value for the
isosurface. If <var>isoval</var> is omitted or empty, a "good" value
for an isosurface is determined from <var>v</var>.
</p>
<p>When called with a single output argument <code>isosurface</code> returns a
structure array <var>fv</var> that contains the fields <var>faces</var> and
<var>vertices</var> computed at the points
<code>[<var>x</var>, <var>y</var>, <var>z</var>] = meshgrid (1:l, 1:m, 1:n)</code> where
<code>[l, m, n] = size (<var>v</var>)</code>. The output <var>fv</var> can be
used directly as input to the <code>patch</code> function.
</p>
<p>If called with additional input arguments <var>x</var>, <var>y</var>, and <var>z</var>
that are three-dimensional arrays with the same size as <var>v</var> or
vectors with lengths corresponding to the dimensions of <var>v</var>, then the
volume data is taken at the specified points. If <var>x</var>, <var>y</var>, or
<var>z</var> are empty, the grid corresponds to the indices (<code>1:n</code>) in
the respective direction (see <a href="#XREFmeshgrid">meshgrid</a>).
</p>
<p>The optional input argument <var>col</var>, which is a three-dimensional array
of the same size as <var>v</var>, specifies coloring of the isosurface. The
color data is interpolated, as necessary, to match <var>isoval</var>. The
output structure array, in this case, has the additional field
<var>facevertexcdata</var>.
</p>
<p>If given the string input argument <code>"noshare"</code>, vertices may be
returned multiple times for different faces. The default behavior is to
eliminate vertices shared by adjacent faces.
</p>
<p>The string input argument <code>"verbose"</code> is supported for <small>MATLAB</small>
compatibility, but has no effect.
</p>
<p>Any string arguments must be passed after the other arguments.
</p>
<p>If called with two or three output arguments, return the information about
the faces <var>f</var>, vertices <var>v</var>, and color data <var>c</var> as separate
arrays instead of a single structure array.
</p>
<p>If called with no output argument, the isosurface geometry is directly
plotted with the <code>patch</code> command and a light object is added to
the axes if not yet present.
</p>
<p>For example,
</p>
<div class="example">
<pre class="example">[x, y, z] = meshgrid (1:5, 1:5, 1:5);
v = rand (5, 5, 5);
isosurface (x, y, z, v, .5);
</pre></div>
<p>will directly draw a random isosurface geometry in a graphics window.
</p>
<p>An example of an isosurface geometry with different additional coloring:
</p>
<div class="example">
<pre class="example">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);
v = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2);
figure ();
subplot (2,2,1); view (-38, 20);
[f, vert] = isosurface (x, y, z, v, iso);
p = patch ("Faces", f, "Vertices", vert, "EdgeColor", "none");
pbaspect ([1 1 1]);
isonormals (x, y, z, v, p)
set (p, "FaceColor", "green", "FaceLighting", "gouraud");
light ("Position", [1 1 5]);
subplot (2,2,2); view (-38, 20);
p = patch ("Faces", f, "Vertices", vert, "EdgeColor", "blue");
pbaspect ([1 1 1]);
isonormals (x, y, z, v, p)
set (p, "FaceColor", "none", "EdgeLighting", "gouraud");
light ("Position", [1 1 5]);
subplot (2,2,3); view (-38, 20);
[f, vert, c] = isosurface (x, y, z, v, iso, y);
p = patch ("Faces", f, "Vertices", vert, "FaceVertexCData", c, ...
"FaceColor", "interp", "EdgeColor", "none");
pbaspect ([1 1 1]);
isonormals (x, y, z, v, p)
set (p, "FaceLighting", "gouraud");
light ("Position", [1 1 5]);
subplot (2,2,4); view (-38, 20);
p = patch ("Faces", f, "Vertices", vert, "FaceVertexCData", c, ...
"FaceColor", "interp", "EdgeColor", "blue");
pbaspect ([1 1 1]);
isonormals (x, y, z, v, p)
set (p, "FaceLighting", "gouraud");
light ("Position", [1 1 5]);
</pre></div>
<p><strong>See also:</strong> <a href="#XREFisonormals">isonormals</a>, <a href="#XREFisocolors">isocolors</a>, <a href="#XREFisocaps">isocaps</a>, <a href="#XREFsmooth3">smooth3</a>, <a href="#XREFreducevolume">reducevolume</a>, <a href="#XREFreducepatch">reducepatch</a>, <a href="Graphics-Objects.html#XREFpatch">patch</a>.
</p></dd></dl>
<span id="XREFisonormals"></span><dl>
<dt id="index-isonormals">: <em><var>vn</var> =</em> <strong>isonormals</strong> <em>(<var>val</var>, <var>vert</var>)</em></dt>
<dt id="index-isonormals-1">: <em><var>vn</var> =</em> <strong>isonormals</strong> <em>(<var>val</var>, <var>hp</var>)</em></dt>
<dt id="index-isonormals-2">: <em><var>vn</var> =</em> <strong>isonormals</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>val</var>, <var>vert</var>)</em></dt>
<dt id="index-isonormals-3">: <em><var>vn</var> =</em> <strong>isonormals</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>val</var>, <var>hp</var>)</em></dt>
<dt id="index-isonormals-4">: <em><var>vn</var> =</em> <strong>isonormals</strong> <em>(…, "negate")</em></dt>
<dt id="index-isonormals-5">: <em></em> <strong>isonormals</strong> <em>(<var>val</var>, <var>hp</var>)</em></dt>
<dt id="index-isonormals-6">: <em></em> <strong>isonormals</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>val</var>, <var>hp</var>)</em></dt>
<dt id="index-isonormals-7">: <em></em> <strong>isonormals</strong> <em>(…, "negate")</em></dt>
<dd>
<p>Calculate normals to an isosurface.
</p>
<p>The vertex normals <var>vn</var> are calculated from the gradient of the
3-dimensional array <var>val</var> (size: lxmxn) containing the data for an
isosurface geometry. The normals point towards smaller values in <var>val</var>.
</p>
<p>If called with one output argument <var>vn</var>, and the second input argument
<var>vert</var> holds the vertices of an isosurface, then the normals <var>vn</var>
are calculated at the vertices <var>vert</var> on a grid given by
<code>[x, y, z] = meshgrid (1:l, 1:m, 1:n)</code>. The output argument
<var>vn</var> has the same size as <var>vert</var> and can be used to set the
<code>"VertexNormals"</code> property of the corresponding patch.
</p>
<p>If called with additional input arguments <var>x</var>, <var>y</var>, and <var>z</var>,
which are 3-dimensional arrays with the same size as <var>val</var>,
then the volume data is taken at these points. Instead of the vertex data
<var>vert</var>, a patch handle <var>hp</var> can be passed to the function.
</p>
<p>If the last input argument is the string <code>"negate"</code>, compute the
reverse vector normals of an isosurface geometry (i.e., pointed towards
larger values in <var>val</var>).
</p>
<p>If no output argument is given, the property <code>"VertexNormals"</code> of
the patch associated with the patch handle <var>hp</var> is changed directly.
</p>
<p><strong>See also:</strong> <a href="#XREFisosurface">isosurface</a>, <a href="#XREFisocolors">isocolors</a>, <a href="#XREFsmooth3">smooth3</a>.
</p></dd></dl>
<span id="XREFisocaps"></span><dl>
<dt id="index-isocaps">: <em><var>fvc</var> =</em> <strong>isocaps</strong> <em>(<var>v</var>, <var>isoval</var>)</em></dt>
<dt id="index-isocaps-1">: <em><var>fvc</var> =</em> <strong>isocaps</strong> <em>(<var>v</var>)</em></dt>
<dt id="index-isocaps-2">: <em><var>fvc</var> =</em> <strong>isocaps</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>v</var>, <var>isoval</var>)</em></dt>
<dt id="index-isocaps-3">: <em><var>fvc</var> =</em> <strong>isocaps</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>v</var>)</em></dt>
<dt id="index-isocaps-4">: <em><var>fvc</var> =</em> <strong>isocaps</strong> <em>(…, <var>which_caps</var>)</em></dt>
<dt id="index-isocaps-5">: <em><var>fvc</var> =</em> <strong>isocaps</strong> <em>(…, <var>which_plane</var>)</em></dt>
<dt id="index-isocaps-6">: <em><var>fvc</var> =</em> <strong>isocaps</strong> <em>(…, <code>"verbose"</code>)</em></dt>
<dt id="index-isocaps-7">: <em>[<var>faces</var>, <var>vertices</var>, <var>fvcdata</var>] =</em> <strong>isocaps</strong> <em>(…)</em></dt>
<dt id="index-isocaps-8">: <em></em> <strong>isocaps</strong> <em>(…)</em></dt>
<dd>
<p>Create end-caps for isosurfaces of 3-D data.
</p>
<p>This function places caps at the open ends of isosurfaces.
</p>
<p>The input argument <var>v</var> is a three-dimensional array that contains data
sampled over a volume.
</p>
<p>The input <var>isoval</var> is a scalar that specifies the value for the
isosurface. If <var>isoval</var> is omitted or empty, a "good" value
for an isosurface is determined from <var>v</var>.
</p>
<p>When called with a single output argument, <code>isocaps</code> returns a
structure array <var>fvc</var> with the fields: <code>faces</code>, <code>vertices</code>,
and <code>facevertexcdata</code>. The results are computed at the points
<code>[<var>x</var>, <var>y</var>, <var>z</var>] = meshgrid (1:l, 1:m, 1:n)</code> where
<code>[l, m, n] = size (<var>v</var>)</code>. The output <var>fvc</var> can be used
directly as input to the <code>patch</code> function.
</p>
<p>If called with additional input arguments <var>x</var>, <var>y</var>, and <var>z</var>
that are three-dimensional arrays with the same size as <var>v</var> or
vectors with lengths corresponding to the dimensions of <var>v</var>, then the
volume data is taken at the specified points. If <var>x</var>, <var>y</var>, or
<var>z</var> are empty, the grid corresponds to the indices (<code>1:n</code>) in
the respective direction (see <a href="#XREFmeshgrid">meshgrid</a>).
</p>
<p>The optional parameter <var>which_caps</var> can have one of the following
string values which defines how the data will be enclosed:
</p>
<dl compact="compact">
<dt><code>"above"</code>, <code>"a"</code> (default)</dt>
<dd><p>for end-caps that enclose the data above <var>isoval</var>.
</p>
</dd>
<dt><code>"below"</code>, <code>"b"</code></dt>
<dd><p>for end-caps that enclose the data below <var>isoval</var>.
</p></dd>
</dl>
<p>The optional parameter <var>which_plane</var> can have one of the following
string values to define which end-cap should be drawn:
</p>
<dl compact="compact">
<dt><code>"all"</code> (default)</dt>
<dd><p>for all of the end-caps.
</p>
</dd>
<dt><code>"xmin"</code></dt>
<dd><p>for end-caps at the lower x-plane of the data.
</p>
</dd>
<dt><code>"xmax"</code></dt>
<dd><p>for end-caps at the upper x-plane of the data.
</p>
</dd>
<dt><code>"ymin"</code></dt>
<dd><p>for end-caps at the lower y-plane of the data.
</p>
</dd>
<dt><code>"ymax"</code></dt>
<dd><p>for end-caps at the upper y-plane of the data.
</p>
</dd>
<dt><code>"zmin"</code></dt>
<dd><p>for end-caps at the lower z-plane of the data.
</p>
</dd>
<dt><code>"zmax"</code></dt>
<dd><p>for end-caps at the upper z-plane of the data.
</p></dd>
</dl>
<p>The string input argument <code>"verbose"</code> is supported for <small>MATLAB</small>
compatibility, but has no effect.
</p>
<p>If called with two or three output arguments, the data for faces
<var>faces</var>, vertices <var>vertices</var>, and the color data
<var>facevertexcdata</var> are returned in separate arrays instead of a single
structure.
</p>
<p>If called with no output argument, the end-caps are drawn directly in the
current figure with the <code>patch</code> command.
</p>
<p><strong>See also:</strong> <a href="#XREFisosurface">isosurface</a>, <a href="#XREFisonormals">isonormals</a>, <a href="Graphics-Objects.html#XREFpatch">patch</a>.
</p></dd></dl>
<span id="XREFisocolors"></span><dl>
<dt id="index-isocolors">: <em><var>cdat</var> =</em> <strong>isocolors</strong> <em>(<var>c</var>, <var>v</var>)</em></dt>
<dt id="index-isocolors-1">: <em><var>cdat</var> =</em> <strong>isocolors</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>c</var>, <var>v</var>)</em></dt>
<dt id="index-isocolors-2">: <em><var>cdat</var> =</em> <strong>isocolors</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>r</var>, <var>g</var>, <var>b</var>, <var>v</var>)</em></dt>
<dt id="index-isocolors-3">: <em><var>cdat</var> =</em> <strong>isocolors</strong> <em>(<var>r</var>, <var>g</var>, <var>b</var>, <var>v</var>)</em></dt>
<dt id="index-isocolors-4">: <em><var>cdat</var> =</em> <strong>isocolors</strong> <em>(…, <var>p</var>)</em></dt>
<dt id="index-isocolors-5">: <em></em> <strong>isocolors</strong> <em>(…)</em></dt>
<dd>
<p>Compute isosurface colors.
</p>
<p>If called with one output argument, and the first input argument <var>c</var>
is a three-dimensional array that contains indexed color values, and the
second input argument <var>v</var> are the vertices of an isosurface geometry,
then return a matrix <var>cdat</var> with color data information for the geometry
at computed points <code>[x, y, z] = meshgrid (1:l, 1:m, 1:n)</code>. The output
argument <var>cdat</var> can be used to manually set the
<code>"FaceVertexCData"</code> property of an isosurface patch object.
</p>
<p>If called with additional input arguments <var>x</var>, <var>y</var> and <var>z</var> which
are three-dimensional arrays of the same size as <var>c</var> then the
color data is taken at those specified points.
</p>
<p>Instead of indexed color data <var>c</var>, <code>isocolors</code> can also be called
with RGB values <var>r</var>, <var>g</var>, <var>b</var>. If input arguments <var>x</var>,
<var>y</var>, <var>z</var> are not given then <code>meshgrid</code> computed values are
used.
</p>
<p>Optionally, a patch handle <var>p</var> can be given as the last input argument
to all function call variations and the vertex data will be extracted
from the isosurface patch object. Finally, if no output argument is given
then the colors of the patch given by the patch handle <var>p</var> are changed.
</p>
<p><strong>See also:</strong> <a href="#XREFisosurface">isosurface</a>, <a href="#XREFisonormals">isonormals</a>.
</p></dd></dl>
<span id="XREFsmooth3"></span><dl>
<dt id="index-smooth3">: <em><var>smoothed_data</var> =</em> <strong>smooth3</strong> <em>(<var>data</var>)</em></dt>
<dt id="index-smooth3-1">: <em><var>smoothed_data</var> =</em> <strong>smooth3</strong> <em>(<var>data</var>, <var>method</var>)</em></dt>
<dt id="index-smooth3-2">: <em><var>smoothed_data</var> =</em> <strong>smooth3</strong> <em>(<var>data</var>, <var>method</var>, <var>sz</var>)</em></dt>
<dt id="index-smooth3-3">: <em><var>smoothed_data</var> =</em> <strong>smooth3</strong> <em>(<var>data</var>, <var>method</var>, <var>sz</var>, <var>std_dev</var>)</em></dt>
<dd><p>Smooth values of 3-dimensional matrix <var>data</var>.
</p>
<p>This function may be used, for example, to reduce the impact of noise in
<var>data</var> before calculating isosurfaces.
</p>
<p><var>data</var> must be a non-singleton 3-dimensional matrix. The output
<var>smoothed_data</var> is a matrix of the same size as <var>data</var>.
</p>
<p>The option input <var>method</var> determines which convolution kernel is used
for the smoothing process. Possible choices:
</p>
<dl compact="compact">
<dt><code>"box"</code>, <code>"b"</code> (default)</dt>
<dd><p>a convolution kernel with sharp edges.
</p>
</dd>
<dt><code>"gaussian"</code>, <code>"g"</code></dt>
<dd><p>a convolution kernel that is represented by a non-correlated trivariate
normal distribution function.
</p></dd>
</dl>
<p><var>sz</var> is either a 3-element vector specifying the size of the
convolution kernel in the x-, y- and z-directions, or a scalar. In the
scalar case the same size is used for all three dimensions
(<code>[<var>sz</var>, <var>sz</var>, <var>sz</var>]</code>). The default value is 3.
</p>
<p>If <var>method</var> is <code>"gaussian"</code> then the optional input <var>std_dev</var>
defines the standard deviation of the trivariate normal distribution
function. <var>std_dev</var> is either a 3-element vector specifying the
standard deviation of the Gaussian convolution kernel in x-, y- and
z-directions, or a scalar. In the scalar case the same value is used for
all three dimensions. The default value is 0.65.
</p>
<p><strong>See also:</strong> <a href="#XREFisosurface">isosurface</a>, <a href="#XREFisonormals">isonormals</a>, <a href="Graphics-Objects.html#XREFpatch">patch</a>.
</p></dd></dl>
<span id="XREFreducevolume"></span><dl>
<dt id="index-reducevolume">: <em>[<var>nx</var>, <var>ny</var>, <var>nz</var>, <var>nv</var>] =</em> <strong>reducevolume</strong> <em>(<var>v</var>, <var>r</var>)</em></dt>
<dt id="index-reducevolume-1">: <em>[<var>nx</var>, <var>ny</var>, <var>nz</var>, <var>nv</var>] =</em> <strong>reducevolume</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>v</var>, <var>r</var>)</em></dt>
<dt id="index-reducevolume-2">: <em><var>nv</var> =</em> <strong>reducevolume</strong> <em>(…)</em></dt>
<dd>
<p>Reduce the volume of the dataset in <var>v</var> according to the values in
<var>r</var>.
</p>
<p><var>v</var> is a matrix that is non-singleton in the first 3 dimensions.
</p>
<p><var>r</var> can either be a vector of 3 elements representing the reduction
factors in the x-, y-, and z-directions or a scalar, in which case the same
reduction factor is used in all three dimensions.
</p>
<p><code>reducevolume</code> reduces the number of elements of <var>v</var> by taking
only every <var>r</var>-th element in the respective dimension.
</p>
<p>Optionally, <var>x</var>, <var>y</var>, and <var>z</var> can be supplied to represent the
set of coordinates of <var>v</var>. They can either be matrices of the same size
as <var>v</var> or vectors with sizes according to the dimensions of <var>v</var>, in
which case they are expanded to matrices (see <a href="#XREFmeshgrid">meshgrid</a>).
</p>
<p>If <code>reducevolume</code> is called with two arguments then <var>x</var>, <var>y</var>,
and <var>z</var> are assumed to match the respective indices of <var>v</var>.
</p>
<p>The reduced matrix is returned in <var>nv</var>.
</p>
<p>Optionally, the reduced set of coordinates are returned in <var>nx</var>,
<var>ny</var>, and <var>nz</var>, respectively.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example"><var>v</var> = reshape (1:6*8*4, [6 8 4]);
<var>nv</var> = reducevolume (<var>v</var>, [4 3 2]);
</pre></div>
<div class="example">
<pre class="example"><var>v</var> = reshape (1:6*8*4, [6 8 4]);
<var>x</var> = 1:3:24; <var>y</var> = -14:5:11; <var>z</var> = linspace (16, 18, 4);
[<var>nx</var>, <var>ny</var>, <var>nz</var>, <var>nv</var>] = reducevolume (<var>x</var>, <var>y</var>, <var>z</var>, <var>v</var>, [4 3 2]);
</pre></div>
<p><strong>See also:</strong> <a href="#XREFisosurface">isosurface</a>, <a href="#XREFisonormals">isonormals</a>.
</p></dd></dl>
<span id="XREFreducepatch"></span><dl>
<dt id="index-reducepatch">: <em><var>reduced_fv</var> =</em> <strong>reducepatch</strong> <em>(<var>fv</var>)</em></dt>
<dt id="index-reducepatch-1">: <em><var>reduced_fv</var> =</em> <strong>reducepatch</strong> <em>(<var>faces</var>, <var>vertices</var>)</em></dt>
<dt id="index-reducepatch-2">: <em><var>reduced_fv</var> =</em> <strong>reducepatch</strong> <em>(<var>patch_handle</var>)</em></dt>
<dt id="index-reducepatch-3">: <em></em> <strong>reducepatch</strong> <em>(<var>patch_handle</var>)</em></dt>
<dt id="index-reducepatch-4">: <em><var>reduced_fv</var> =</em> <strong>reducepatch</strong> <em>(…, <var>reduction_factor</var>)</em></dt>
<dt id="index-reducepatch-5">: <em><var>reduced_fv</var> =</em> <strong>reducepatch</strong> <em>(…, "fast")</em></dt>
<dt id="index-reducepatch-6">: <em><var>reduced_fv</var> =</em> <strong>reducepatch</strong> <em>(…, "verbose")</em></dt>
<dt id="index-reducepatch-7">: <em>[<var>reduced_faces</var>, <var>reduces_vertices</var>] =</em> <strong>reducepatch</strong> <em>(…)</em></dt>
<dd>
<p>Reduce the number of faces and vertices in a patch object while retaining
the overall shape of the patch.
</p>
<p>The input patch can be represented by a structure <var>fv</var> with the
fields <code>faces</code> and <code>vertices</code>, by two matrices <var>faces</var> and
<var>vertices</var> (see, e.g., the result of <code>isosurface</code>), or by a
handle to a patch object <var>patch_handle</var> (see <a href="Graphics-Objects.html#XREFpatch">patch</a>).
</p>
<p>The number of faces and vertices in the patch is reduced by iteratively
collapsing the shortest edge of the patch to its midpoint (as discussed,
e.g., here:
<a href="https://libigl.github.io/libigl/tutorial/tutorial.html#meshdecimation">https://libigl.github.io/libigl/tutorial/tutorial.html#meshdecimation</a>).
</p>
<p>Currently, only patches consisting of triangles are supported. The
resulting patch also consists only of triangles.
</p>
<p>If <code>reducepatch</code> is called with a handle to a valid patch
<var>patch_handle</var>, and without any output arguments, then the given
patch is updated immediately.
</p>
<p>If the <var>reduction_factor</var> is omitted, the resulting structure
<var>reduced_fv</var> includes approximately 50% of the faces of the original
patch. If <var>reduction_factor</var> is a fraction between 0 (excluded) and 1
(excluded), a patch with approximately the corresponding fraction of faces
is determined.
If <var>reduction_factor</var> is an integer greater than or equal to 1, the
resulting patch has approximately <var>reduction_factor</var> faces. Depending
on the geometry of the patch, the resulting number of faces can differ from
the given value of <var>reduction_factor</var>. This is especially true when
many shared vertices are detected.
</p>
<p>For the reduction, it is necessary that vertices of touching faces are
shared. Shared vertices are detected automatically. This detection can be
skipped by passing the optional string argument <code>"fast"</code>.
</p>
<p>With the optional string arguments <code>"verbose"</code>, additional status
messages are printed to the command window.
</p>
<p>Any string input arguments must be passed after all other arguments.
</p>
<p>If called with one output argument, the reduced faces and vertices are
returned in a structure <var>reduced_fv</var> with the fields <code>faces</code> and
<code>vertices</code> (see the one output option of <code>isosurface</code>).
</p>
<p>If called with two output arguments, the reduced faces and vertices are
returned in two separate matrices <var>reduced_faces</var> and
<var>reduced_vertices</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFisosurface">isosurface</a>, <a href="#XREFisonormals">isonormals</a>, <a href="#XREFreducevolume">reducevolume</a>, <a href="Graphics-Objects.html#XREFpatch">patch</a>.
</p></dd></dl>
<span id="XREFshrinkfaces"></span><dl>
<dt id="index-shrinkfaces">: <em></em> <strong>shrinkfaces</strong> <em>(<var>p</var>, <var>sf</var>)</em></dt>
<dt id="index-shrinkfaces-1">: <em><var>nfv</var> =</em> <strong>shrinkfaces</strong> <em>(<var>p</var>, <var>sf</var>)</em></dt>
<dt id="index-shrinkfaces-2">: <em><var>nfv</var> =</em> <strong>shrinkfaces</strong> <em>(<var>fv</var>, <var>sf</var>)</em></dt>
<dt id="index-shrinkfaces-3">: <em><var>nfv</var> =</em> <strong>shrinkfaces</strong> <em>(<var>f</var>, <var>v</var>, <var>sf</var>)</em></dt>
<dt id="index-shrinkfaces-4">: <em>[<var>nf</var>, <var>nv</var>] =</em> <strong>shrinkfaces</strong> <em>(…)</em></dt>
<dd>
<p>Reduce the size of faces in a patch by the shrink factor <var>sf</var>.
</p>
<p>The patch object can be specified by a graphics handle (<var>p</var>), a patch
structure (<var>fv</var>) with the fields <code>"faces"</code> and <code>"vertices"</code>,
or as two separate matrices (<var>f</var>, <var>v</var>) of faces and vertices.
</p>
<p>The shrink factor <var>sf</var> 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.
</p>
<p>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.
</p>
<p>If called with one output argument, return a structure with fields
<code>"faces"</code>, <code>"vertices"</code>, and <code>"facevertexcdata"</code>
containing the data after shrinking. This structure can be used directly
as an input argument to the <code>patch</code> function.
</p>
<p><strong>Caution:</strong>: Performing the shrink operation on faces which are not
convex can lead to undesirable results.
</p>
<p>Example: a triangulated 3/4 circle and the corresponding shrunken version.
</p>
<div class="example">
<pre class="example">[phi r] = meshgrid (linspace (0, 1.5*pi, 16), linspace (1, 2, 4));
tri = delaunay (phi(:), r(:));
v = [r(:).*sin(phi(:)) r(:).*cos(phi(:))];
clf ()
p = patch ("Faces", tri, "Vertices", v, "FaceColor", "none");
fv = shrinkfaces (p);
patch (fv)
axis equal
grid on
</pre></div>
<p><strong>See also:</strong> <a href="Graphics-Objects.html#XREFpatch">patch</a>.
</p></dd></dl>
<span id="XREFdiffuse"></span><dl>
<dt id="index-diffuse">: <em></em> <strong>diffuse</strong> <em>(<var>sx</var>, <var>sy</var>, <var>sz</var>, <var>lv</var>)</em></dt>
<dd><p>Calculate the diffuse reflection strength of a surface defined by the normal
vector elements <var>sx</var>, <var>sy</var>, <var>sz</var>.
</p>
<p>The light source location vector <var>lv</var> can be given as a 2-element vector
[azimuth, elevation] in degrees or as a 3-element vector [x, y, z].
</p>
<p><strong>See also:</strong> <a href="#XREFspecular">specular</a>, <a href="#XREFsurfl">surfl</a>.
</p></dd></dl>
<span id="XREFspecular"></span><dl>
<dt id="index-specular">: <em></em> <strong>specular</strong> <em>(<var>sx</var>, <var>sy</var>, <var>sz</var>, <var>lv</var>, <var>vv</var>)</em></dt>
<dt id="index-specular-1">: <em></em> <strong>specular</strong> <em>(<var>sx</var>, <var>sy</var>, <var>sz</var>, <var>lv</var>, <var>vv</var>, <var>se</var>)</em></dt>
<dd><p>Calculate the specular reflection strength of a surface defined by the
normal vector elements <var>sx</var>, <var>sy</var>, <var>sz</var> using Phong’s
approximation.
</p>
<p>The light source location and viewer location vectors are specified using
parameters <var>lv</var> and <var>vv</var> respectively. The location vectors can
given as 2-element vectors [azimuth, elevation] in degrees or as 3-element
vectors [x, y, z].
</p>
<p>An optional sixth argument specifies the specular exponent (spread)
<var>se</var>. If not given, <var>se</var> defaults to 10.
</p>
<p><strong>See also:</strong> <a href="#XREFdiffuse">diffuse</a>, <a href="#XREFsurfl">surfl</a>.
</p></dd></dl>
<span id="XREFlighting"></span><dl>
<dt id="index-lighting">: <em></em> <strong>lighting</strong> <em>(<var>type</var>)</em></dt>
<dt id="index-lighting-1">: <em></em> <strong>lighting</strong> <em>(<var>hax</var>, <var>type</var>)</em></dt>
<dd><p>Set the lighting of patch or surface graphic objects.
</p>
<p>Valid arguments for <var>type</var> are
</p>
<dl compact="compact">
<dt><code>"flat"</code></dt>
<dd><p>Draw objects with faceted lighting effects.
</p>
</dd>
<dt><code>"gouraud"</code></dt>
<dd><p>Draw objects with linear interpolation of the lighting effects between the
vertices.
</p>
</dd>
<dt><code>"none"</code></dt>
<dd><p>Draw objects without light and shadow effects.
</p></dd>
</dl>
<p>If the first argument <var>hax</var> is an axes handle, then change the lighting
effects of objects in this axes, rather than the current axes returned by
<code>gca</code>.
</p>
<p>The lighting effects are only visible if at least one light object is
present and visible in the same axes.
</p>
<p><strong>See also:</strong> <a href="Graphics-Objects.html#XREFlight">light</a>, <a href="Two_002dDimensional-Plots.html#XREFfill">fill</a>, <a href="#XREFmesh">mesh</a>, <a href="Graphics-Objects.html#XREFpatch">patch</a>, <a href="Two_002dDimensional-Plots.html#XREFpcolor">pcolor</a>, <a href="#XREFsurf">surf</a>, <a href="Graphics-Objects.html#XREFsurface">surface</a>, <a href="#XREFshading">shading</a>.
</p></dd></dl>
<span id="XREFmaterial"></span><dl>
<dt id="index-material">: <em></em> <strong>material</strong> <em>shiny</em></dt>
<dt id="index-material-1">: <em></em> <strong>material</strong> <em>dull</em></dt>
<dt id="index-material-2">: <em></em> <strong>material</strong> <em>metal</em></dt>
<dt id="index-material-3">: <em></em> <strong>material</strong> <em>default</em></dt>
<dt id="index-material-4">: <em></em> <strong>material</strong> <em>([<var>as</var>, <var>ds</var>, <var>ss</var>])</em></dt>
<dt id="index-material-5">: <em></em> <strong>material</strong> <em>([<var>as</var>, <var>ds</var>, <var>ss</var>, <var>se</var>])</em></dt>
<dt id="index-material-6">: <em></em> <strong>material</strong> <em>([<var>as</var>, <var>ds</var>, <var>ss</var>, <var>se</var>, <var>scr</var>])</em></dt>
<dt id="index-material-7">: <em></em> <strong>material</strong> <em>(<var>hlist</var>, …)</em></dt>
<dt id="index-material-8">: <em><var>mtypes</var> =</em> <strong>material</strong> <em>()</em></dt>
<dt id="index-material-9">: <em><var>refl_props</var> =</em> <strong>material</strong> <em>(<var>mtype_string</var>)</em></dt>
<dd><p>Set reflectance properties for the lighting of surfaces and patches.
</p>
<p>This function changes the ambient, diffuse, and specular strengths, as well
as the specular exponent and specular color reflectance, of all
<code>patch</code> and <code>surface</code> objects in the current axes. This can be
used to simulate, to some extent, the reflectance properties of certain
materials when used with <code>light</code>.
</p>
<p>When called with a string, the aforementioned properties are set
according to the values in the following table:
</p>
<table>
<thead><tr><th width="0%"></th><th width="20%"><var>mtype</var></th><th width="15%">ambient- strength</th><th width="15%">diffuse-
strength</th><th width="15%">specular- strength</th><th width="15%">specular- exponent</th><th width="15%">specular-
color- reflectance</th><th width="0%"></th></tr></thead>
<tr><td width="0%"></td><td width="20%"><code>"shiny"</code></td><td width="15%">0.3</td><td width="15%">0.6</td><td width="15%">0.9</td><td width="15%">20</td><td width="15%">1.0</td><td width="0%"></td></tr>
<tr><td width="0%"></td><td width="20%"><code>"dull"</code></td><td width="15%">0.3</td><td width="15%">0.8</td><td width="15%">0.0</td><td width="15%">10</td><td width="15%">1.0</td><td width="0%"></td></tr>
<tr><td width="0%"></td><td width="20%"><code>"metal"</code></td><td width="15%">0.3</td><td width="15%">0.3</td><td width="15%">1.0</td><td width="15%">25</td><td width="15%">0.5</td><td width="0%"></td></tr>
<tr><td width="0%"></td><td width="20%"><code>"default"</code></td><td width="15%"><code>"default"</code></td><td width="15%"><code>"default"</code></td><td width="15%"><code>"default"</code></td><td width="15%"><code>"default"</code></td><td width="15%"><code>"default"</code></td><td width="0%"></td></tr>
</table>
<p>When called with a vector of three elements, the ambient, diffuse, and
specular strengths of all <code>patch</code> and <code>surface</code> objects in the
current axes are updated. An optional fourth vector element updates the
specular exponent, and an optional fifth vector element updates the
specular color reflectance.
</p>
<p>A list of graphic handles can also be passed as the first argument. In
this case, the properties of these handles and all child <code>patch</code> and
<code>surface</code> objects will be updated.
</p>
<p>Additionally, <code>material</code> can be called with a single output argument.
If called without input arguments, a column cell vector <var>mtypes</var> with
the strings for all available materials is returned. If the one input
argument <var>mtype_string</var> is the name of a material, a 1x5 cell vector
<var>refl_props</var> with the reflectance properties of that material is
returned. In both cases, no graphic properties are changed.
</p>
<p><strong>See also:</strong> <a href="Graphics-Objects.html#XREFlight">light</a>, <a href="Two_002dDimensional-Plots.html#XREFfill">fill</a>, <a href="#XREFmesh">mesh</a>, <a href="Graphics-Objects.html#XREFpatch">patch</a>, <a href="Two_002dDimensional-Plots.html#XREFpcolor">pcolor</a>, <a href="#XREFsurf">surf</a>, <a href="Graphics-Objects.html#XREFsurface">surface</a>.
</p></dd></dl>
<span id="XREFcamlight"></span><dl>
<dt id="index-camlight">: <em></em> <strong>camlight</strong> <em></em></dt>
<dt id="index-camlight-1">: <em></em> <strong>camlight</strong> <em>right</em></dt>
<dt id="index-camlight-2">: <em></em> <strong>camlight</strong> <em>left</em></dt>
<dt id="index-camlight-3">: <em></em> <strong>camlight</strong> <em>headlight</em></dt>
<dt id="index-camlight-4">: <em></em> <strong>camlight</strong> <em>(<var>az</var>, <var>el</var>)</em></dt>
<dt id="index-camlight-5">: <em></em> <strong>camlight</strong> <em>(…, <var>style</var>)</em></dt>
<dt id="index-camlight-6">: <em></em> <strong>camlight</strong> <em>(<var>hl</var>, …)</em></dt>
<dt id="index-camlight-7">: <em></em> <strong>camlight</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-camlight-8">: <em><var>h</var> =</em> <strong>camlight</strong> <em>(…)</em></dt>
<dd><p>Add a light object to a figure using a simple interface.
</p>
<p>When called with no arguments, a light object is added to the current plot
and is placed slightly above and to the right of the camera’s current
position: this is equivalent to <code>camlight right</code>. The commands
<code>camlight left</code> and <code>camlight headlight</code> behave similarly with
the placement being either left of the camera position or centered on the
camera position.
</p>
<p>For more control, the light position can be specified by an azimuthal
rotation <var>az</var> and an elevation angle <var>el</var>, both in degrees,
relative to the current properties of the camera.
</p>
<p>The optional string <var>style</var> specifies whether the light is a local point
source (<code>"local"</code>, the default) or placed at infinite distance
(<code>"infinite"</code>).
</p>
<p>If the first argument <var>hl</var> is a handle to a light object, then act on
this light object rather than creating a new object.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then create a new light
object in this axes, rather than the current axes returned by <code>gca</code>.
</p>
<p>The optional return value <var>h</var> is a graphics handle to the light object.
This can be used to move or further change properties of the light object.
</p>
<p>Examples:
</p>
<p>Add a light object to a plot
</p>
<div class="example">
<pre class="example">sphere (36);
camlight
</pre></div>
<p>Position the light source exactly
</p>
<div class="example">
<pre class="example">camlight (45, 30);
</pre></div>
<p>Here the light is first pitched upwards (see <a href="#XREFcamup">camup</a>) from the
camera position (see <a href="#XREFcampos">campos</a>) by 30 degrees. It is then
yawed by 45 degrees to the right. Both rotations are centered around the
camera target (see <a href="#XREFcamtarget">camtarget</a>).
</p>
<p>Return a handle to further manipulate the light object
</p>
<div class="example">
<pre class="example">clf
sphere (36);
hl = camlight ("left");
set (hl, "color", "r");
</pre></div>
<p><strong>See also:</strong> <a href="Graphics-Objects.html#XREFlight">light</a>.
</p></dd></dl>
<span id="XREFlightangle"></span><dl>
<dt id="index-lightangle">: <em></em> <strong>lightangle</strong> <em>(<var>az</var>, <var>el</var>)</em></dt>
<dt id="index-lightangle-1">: <em></em> <strong>lightangle</strong> <em>(<var>hax</var>, <var>az</var>, <var>el</var>)</em></dt>
<dt id="index-lightangle-2">: <em></em> <strong>lightangle</strong> <em>(<var>hl</var>, <var>az</var>, <var>el</var>)</em></dt>
<dt id="index-lightangle-3">: <em><var>hl</var> =</em> <strong>lightangle</strong> <em>(…)</em></dt>
<dt id="index-lightangle-4">: <em>[<var>az</var>, <var>el</var>] =</em> <strong>lightangle</strong> <em>(<var>hl</var>)</em></dt>
<dd><p>Add a light object to the current axes using spherical coordinates.
</p>
<p>The light position is specified by an azimuthal rotation <var>az</var> and an
elevation angle <var>el</var>, both in degrees.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then create a new light
object in this axes, rather than the current axes returned by <code>gca</code>.
</p>
<p>If the first argument <var>hl</var> is a handle to a light object, then act on
this light object rather than creating a new object.
</p>
<p>The optional return value <var>hl</var> is a graphics handle to the light object.
</p>
<p>Example:
</p>
<p>Add a light object to a plot
</p>
<div class="example">
<pre class="example">clf;
sphere (36);
lightangle (45, 30);
</pre></div>
<p><strong>See also:</strong> <a href="Graphics-Objects.html#XREFlight">light</a>, <a href="#XREFview">view</a>, <a href="#XREFcamlight">camlight</a>.
</p></dd></dl>
<span id="XREFmeshgrid"></span><dl>
<dt id="index-meshgrid">: <em>[<var>xx</var>, <var>yy</var>] =</em> <strong>meshgrid</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dt id="index-meshgrid-1">: <em>[<var>xx</var>, <var>yy</var>, <var>zz</var>] =</em> <strong>meshgrid</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>)</em></dt>
<dt id="index-meshgrid-2">: <em>[<var>xx</var>, <var>yy</var>] =</em> <strong>meshgrid</strong> <em>(<var>x</var>)</em></dt>
<dt id="index-meshgrid-3">: <em>[<var>xx</var>, <var>yy</var>, <var>zz</var>] =</em> <strong>meshgrid</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Given vectors of <var>x</var> and <var>y</var> coordinates, return matrices <var>xx</var>
and <var>yy</var> corresponding to a full 2-D grid.
</p>
<p>The rows of <var>xx</var> are copies of <var>x</var>, and the columns of <var>yy</var> are
copies of <var>y</var>. If <var>y</var> is omitted, then it is assumed to be the same
as <var>x</var>.
</p>
<p>If the optional <var>z</var> input is given, or <var>zz</var> is requested, then the
output will be a full 3-D grid. If <var>z</var> is omitted and <var>zz</var> is
requested, it is assumed to be the same as <var>y</var>.
</p>
<p><code>meshgrid</code> 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.
</p>
<div class="example">
<pre class="example">f = @(x,y) sin (sqrt (x.^2 + y.^2)) ./ sqrt (x.^2 + y.^2);
range = linspace (-8, 8, 41);
[<var>X</var>, <var>Y</var>] = meshgrid (range, range);
Z = f (X, Y);
surf (X, Y, Z);
</pre></div>
<p>Programming Note: <code>meshgrid</code> is restricted to 2-D or 3-D grid
generation. The <code>ndgrid</code> function will generate 1-D through N-D
grids. However, the functions are not completely equivalent. If <var>x</var>
is a vector of length M and <var>y</var> is a vector of length N, then
<code>meshgrid</code> will produce an output grid which is NxM. <code>ndgrid</code>
will produce an output which is MxN (transpose) for the same
input. Some core functions expect <code>meshgrid</code> input and others expect
<code>ndgrid</code> input. Check the documentation for the function in question
to determine the proper input format.
</p>
<p><strong>See also:</strong> <a href="#XREFndgrid">ndgrid</a>, <a href="#XREFmesh">mesh</a>, <a href="Two_002dDimensional-Plots.html#XREFcontour">contour</a>, <a href="#XREFsurf">surf</a>.
</p></dd></dl>
<span id="XREFndgrid"></span><dl>
<dt id="index-ndgrid">: <em>[<var>y1</var>, <var>y2</var>, …, <var>y</var>n] =</em> <strong>ndgrid</strong> <em>(<var>x1</var>, <var>x2</var>, …, <var>x</var>n)</em></dt>
<dt id="index-ndgrid-1">: <em>[<var>y1</var>, <var>y2</var>, …, <var>y</var>n] =</em> <strong>ndgrid</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Given n vectors <var>x1</var>, …, <var>x</var>n, <code>ndgrid</code> returns n
arrays of dimension n.
</p>
<p>The elements of the i-th output argument contains the elements of the
vector <var>x</var>i repeated over all dimensions different from the i-th
dimension. Calling ndgrid with only one input argument <var>x</var> is
equivalent to calling ndgrid with all n input arguments equal to <var>x</var>:
</p>
<p>[<var>y1</var>, <var>y2</var>, …, <var>y</var>n] = ndgrid (<var>x</var>, …, <var>x</var>)
</p>
<p>Programming Note: <code>ndgrid</code> is very similar to the function
<code>meshgrid</code> except that the first two dimensions are transposed in
comparison to <code>meshgrid</code>. Some core functions expect <code>meshgrid</code>
input and others expect <code>ndgrid</code> input. Check the documentation for
the function in question to determine the proper input format.
</p>
<p><strong>See also:</strong> <a href="#XREFmeshgrid">meshgrid</a>.
</p></dd></dl>
<span id="XREFplot3"></span><dl>
<dt id="index-plot3">: <em></em> <strong>plot3</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>)</em></dt>
<dt id="index-plot3-1">: <em></em> <strong>plot3</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>prop</var>, <var>value</var>, …)</em></dt>
<dt id="index-plot3-2">: <em></em> <strong>plot3</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>fmt</var>)</em></dt>
<dt id="index-plot3-3">: <em></em> <strong>plot3</strong> <em>(<var>x</var>, <var>cplx</var>)</em></dt>
<dt id="index-plot3-4">: <em></em> <strong>plot3</strong> <em>(<var>cplx</var>)</em></dt>
<dt id="index-plot3-5">: <em></em> <strong>plot3</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-plot3-6">: <em><var>h</var> =</em> <strong>plot3</strong> <em>(…)</em></dt>
<dd><p>Produce 3-D plots.
</p>
<p>Many different combinations of arguments are possible. The simplest
form is
</p>
<div class="example">
<pre class="example">plot3 (<var>x</var>, <var>y</var>, <var>z</var>)
</pre></div>
<p>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.
</p>
<p>If only two arguments are given, as
</p>
<div class="example">
<pre class="example">plot3 (<var>x</var>, <var>cplx</var>)
</pre></div>
<p>the real and imaginary parts of the second argument are used
as the <var>y</var> and <var>z</var> coordinates, respectively.
</p>
<p>If only one argument is given, as
</p>
<div class="example">
<pre class="example">plot3 (<var>cplx</var>)
</pre></div>
<p>the real and imaginary parts of the argument are used as the <var>y</var>
and <var>z</var> values, and they are plotted versus their index.
</p>
<p>Arguments may also be given in groups of three as
</p>
<div class="example">
<pre class="example">plot3 (<var>x1</var>, <var>y1</var>, <var>z1</var>, <var>x2</var>, <var>y2</var>, <var>z2</var>, …)
</pre></div>
<p>in which each set of three arguments is treated as a separate line or
set of lines in three dimensions.
</p>
<p>To plot multiple one- or two-argument groups, separate each group
with an empty format string, as
</p>
<div class="example">
<pre class="example">plot3 (<var>x1</var>, <var>c1</var>, "", <var>c2</var>, "", …)
</pre></div>
<p>Multiple property-value pairs may be specified which will affect the line
objects drawn by <code>plot3</code>. If the <var>fmt</var> argument is supplied it
will format the line objects in the same manner as <code>plot</code>.
The full list of properties is documented at
<a href="Line-Properties.html">Line Properties</a>.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p>The optional return value <var>h</var> is a graphics handle to the created plot.
</p>
<p>Example:
</p>
<div class="example">
<pre class="example">z = [0:0.05:5];
plot3 (cos (2*pi*z), sin (2*pi*z), z, ";helix;");
plot3 (z, exp (2i*pi*z), ";complex sinusoid;");
</pre></div>
<p><strong>See also:</strong> <a href="Three_002ddimensional-Function-Plotting.html#XREFezplot3">ezplot3</a>, <a href="Two_002dDimensional-Plots.html#XREFplot">plot</a>.
</p></dd></dl>
<span id="XREFview"></span><dl>
<dt id="index-view">: <em></em> <strong>view</strong> <em>(<var>azimuth</var>, <var>elevation</var>)</em></dt>
<dt id="index-view-1">: <em></em> <strong>view</strong> <em>([<var>azimuth</var> <var>elevation</var>])</em></dt>
<dt id="index-view-2">: <em></em> <strong>view</strong> <em>([<var>x</var> <var>y</var> <var>z</var>])</em></dt>
<dt id="index-view-3">: <em></em> <strong>view</strong> <em>(2)</em></dt>
<dt id="index-view-4">: <em></em> <strong>view</strong> <em>(3)</em></dt>
<dt id="index-view-5">: <em></em> <strong>view</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-view-6">: <em>[<var>azimuth</var>, <var>elevation</var>] =</em> <strong>view</strong> <em>()</em></dt>
<dd><p>Query or set the viewpoint for the current axes.
</p>
<p>The parameters <var>azimuth</var> and <var>elevation</var> can be given as two
arguments or as 2-element vector. The viewpoint can also be specified with
Cartesian coordinates <var>x</var>, <var>y</var>, and <var>z</var>.
</p>
<p>The call <code>view (2)</code> sets the viewpoint to <var>azimuth</var> = 0<!-- /@w -->
and <var>elevation</var> = 90<!-- /@w -->, which is the default for 2-D graphs.
</p>
<p>The call <code>view (3)</code> sets the viewpoint to <var>azimuth</var> = <span class="nolinebreak">-37.5</span><!-- /@w -->
and <var>elevation</var> = 30<!-- /@w -->, which is the default for 3-D graphs.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then operate on
this axes rather than the current axes returned by <code>gca</code>.
</p>
<p>If no inputs are given, return the current <var>azimuth</var> and
<var>elevation</var>.
</p></dd></dl>
<span id="XREFcamlookat"></span><dl>
<dt id="index-camlookat">: <em></em> <strong>camlookat</strong> <em>()</em></dt>
<dt id="index-camlookat-1">: <em></em> <strong>camlookat</strong> <em>(<var>h</var>)</em></dt>
<dt id="index-camlookat-2">: <em></em> <strong>camlookat</strong> <em>(<var>handle_list</var>)</em></dt>
<dt id="index-camlookat-3">: <em></em> <strong>camlookat</strong> <em>(<var>hax</var>)</em></dt>
<dd><p>Move the camera and adjust its properties to look at objects.
</p>
<p>When the input is a handle <var>h</var>, the camera is set to point toward the
center of the bounding box of <var>h</var>. The camera’s position is adjusted so
the bounding box approximately fills the field of view.
</p>
<p>This command fixes the camera’s viewing direction
(<code>camtarget() - campos()</code>), camera up vector (see <a href="#XREFcamup">camup</a>)
and viewing angle (see <a href="#XREFcamva">camva</a>). The camera target
(see <a href="#XREFcamtarget">camtarget</a>) and camera position
(see <a href="#XREFcampos">campos</a>) are changed.
</p>
<p>If the argument is a list <var>handle_list</var>, then a single bounding box for
all the objects is computed and the camera is then adjusted as above.
</p>
<p>If the argument is an axis object <var>hax</var>, then the children of the axis
are used as <var>handle_list</var>. When called with no inputs, it uses the
current axis (see <a href="Graphics-Objects.html#XREFgca">gca</a>).
</p>
<p><strong>See also:</strong> <a href="#XREFcamorbit">camorbit</a>, <a href="#XREFcamzoom">camzoom</a>, <a href="#XREFcamroll">camroll</a>.
</p></dd></dl>
<span id="XREFcampos"></span><dl>
<dt id="index-campos">: <em><var>P</var> =</em> <strong>campos</strong> <em>()</em></dt>
<dt id="index-campos-1">: <em></em> <strong>campos</strong> <em>([<var>x</var> <var>y</var> <var>z</var>])</em></dt>
<dt id="index-campos-2">: <em><var>mode</var> =</em> <strong>campos</strong> <em>("mode")</em></dt>
<dt id="index-campos-3">: <em></em> <strong>campos</strong> <em>(<var>mode</var>)</em></dt>
<dt id="index-campos-4">: <em></em> <strong>campos</strong> <em>(<var>ax</var>, …)</em></dt>
<dd><p>Set or get the camera position.
</p>
<p>The default camera position is determined automatically based on the scene.
For example, to get the camera position:
</p>
<div class="example">
<pre class="example">hf = figure();
peaks()
p = campos ()
⇒ p =
-27.394 -35.701 64.079
</pre></div>
<p>We can then move the camera further up the z-axis:
</p>
<div class="example">
<pre class="example">campos (p + [0 0 10])
campos ()
⇒ ans =
-27.394 -35.701 74.079
</pre></div>
<p>Having made that change, the camera position <var>mode</var> is now manual:
</p>
<div class="example">
<pre class="example">campos ("mode")
⇒ manual
</pre></div>
<p>We can set it back to automatic:
</p>
<div class="example">
<pre class="example">campos ("auto")
campos ()
⇒ ans =
-27.394 -35.701 64.079
close (hf)
</pre></div>
<p>By default, these commands affect the current axis; alternatively, an axis
can be specified by the optional argument <var>ax</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcamup">camup</a>, <a href="#XREFcamtarget">camtarget</a>, <a href="#XREFcamva">camva</a>.
</p></dd></dl>
<span id="XREFcamorbit"></span><dl>
<dt id="index-camorbit">: <em></em> <strong>camorbit</strong> <em>(<var>theta</var>, <var>phi</var>)</em></dt>
<dt id="index-camorbit-1">: <em></em> <strong>camorbit</strong> <em>(<var>theta</var>, <var>phi</var>, <var>coorsys</var>)</em></dt>
<dt id="index-camorbit-2">: <em></em> <strong>camorbit</strong> <em>(<var>theta</var>, <var>phi</var>, <var>coorsys</var>, <var>dir</var>)</em></dt>
<dt id="index-camorbit-3">: <em></em> <strong>camorbit</strong> <em>(<var>theta</var>, <var>phi</var>, "data")</em></dt>
<dt id="index-camorbit-4">: <em></em> <strong>camorbit</strong> <em>(<var>theta</var>, <var>phi</var>, "data", "z")</em></dt>
<dt id="index-camorbit-5">: <em></em> <strong>camorbit</strong> <em>(<var>theta</var>, <var>phi</var>, "data", "x")</em></dt>
<dt id="index-camorbit-6">: <em></em> <strong>camorbit</strong> <em>(<var>theta</var>, <var>phi</var>, "data", "y")</em></dt>
<dt id="index-camorbit-7">: <em></em> <strong>camorbit</strong> <em>(<var>theta</var>, <var>phi</var>, "data", [<var>x</var> <var>y</var> <var>z</var>])</em></dt>
<dt id="index-camorbit-8">: <em></em> <strong>camorbit</strong> <em>(<var>theta</var>, <var>phi</var>, "camera")</em></dt>
<dt id="index-camorbit-9">: <em></em> <strong>camorbit</strong> <em>(<var>hax</var>, …)</em></dt>
<dd><p>Rotate the camera up/down and left/right around its target.
</p>
<p>Move the camera <var>phi</var> degrees up and <var>theta</var> degrees to the right,
as if it were in an orbit around its target.
Example:
</p>
<div class="example">
<pre class="example">sphere ()
camorbit (30, 20)
</pre></div>
<p>These rotations are centered around the camera target
(see <a href="#XREFcamtarget">camtarget</a>).
First the camera position is pitched up or down by rotating it <var>phi</var>
degrees around an axis orthogonal to both the viewing direction
(specifically <code>camtarget() - campos()</code>) and the camera “up vector”
(see <a href="#XREFcamup">camup</a>).
Example:
</p>
<div class="example">
<pre class="example">camorbit (0, 20)
</pre></div>
<p>The second rotation depends on the coordinate system <var>coorsys</var> and
direction <var>dir</var> inputs.
The default for <var>coorsys</var> is <code>"data"</code>. In this case, the camera
is yawed left or right by rotating it <var>theta</var> degrees around an axis
specified by <var>dir</var>.
The default for <var>dir</var> is <code>"z"</code>, corresponding to the vector
<code>[0, 0, 1]</code>.
Example:
</p>
<div class="example">
<pre class="example">camorbit (30, 0)
</pre></div>
<p>When <var>coorsys</var> is set to <code>"camera"</code>, the camera is moved left or
right by rotating it around an axis parallel to the camera up vector
(see <a href="#XREFcamup">camup</a>).
The input <var>dir</var> should not be specified in this case.
Example:
</p>
<div class="example">
<pre class="example">camorbit (30, 0, "camera")
</pre></div>
<p>(Note: the rotation by <var>phi</var> is unaffected by <code>"camera"</code>.)
</p>
<p>The <code>camorbit</code> command modifies two camera properties:
<a href="#XREFcampos">campos</a> and <a href="#XREFcamup">camup</a>.
</p>
<p>By default, this command affects the current axis; alternatively, an axis
can be specified by the optional argument <var>hax</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcamzoom">camzoom</a>, <a href="#XREFcamroll">camroll</a>, <a href="#XREFcamlookat">camlookat</a>.
</p></dd></dl>
<span id="XREFcamroll"></span><dl>
<dt id="index-camroll">: <em></em> <strong>camroll</strong> <em>(<var>theta</var>)</em></dt>
<dt id="index-camroll-1">: <em></em> <strong>camroll</strong> <em>(<var>ax</var>, <var>theta</var>)</em></dt>
<dd><p>Roll the camera.
</p>
<p>Roll the camera clockwise by <var>theta</var> degrees.
For example, the following command will roll the camera by
30 degrees clockwise (to the right); this will cause the scene
to appear to roll by 30 degrees to the left:
</p>
<div class="example">
<pre class="example">peaks ()
camroll (30)
</pre></div>
<p>Roll the camera back:
</p>
<div class="example">
<pre class="example">camroll (-30)
</pre></div>
<p>The following command restores the default camera roll:
</p>
<div class="example">
<pre class="example">camup ("auto")
</pre></div>
<p>By default, these commands affect the current axis; alternatively, an axis
can be specified by the optional argument <var>ax</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcamzoom">camzoom</a>, <a href="#XREFcamorbit">camorbit</a>, <a href="#XREFcamlookat">camlookat</a>, <a href="#XREFcamup">camup</a>.
</p></dd></dl>
<span id="XREFcamtarget"></span><dl>
<dt id="index-camtarget">: <em><var>T</var> =</em> <strong>camtarget</strong> <em>()</em></dt>
<dt id="index-camtarget-1">: <em></em> <strong>camtarget</strong> <em>([<var>x</var> <var>y</var> <var>z</var>])</em></dt>
<dt id="index-camtarget-2">: <em><var>mode</var> =</em> <strong>camtarget</strong> <em>("mode")</em></dt>
<dt id="index-camtarget-3">: <em></em> <strong>camtarget</strong> <em>(<var>mode</var>)</em></dt>
<dt id="index-camtarget-4">: <em></em> <strong>camtarget</strong> <em>(<var>ax</var>, …)</em></dt>
<dd><p>Set or get where the camera is pointed.
</p>
<p>The camera target is a point in space where the camera is pointing.
Usually, it is determined automatically based on the scene:
</p>
<div class="example">
<pre class="example">hf = figure();
sphere (36)
v = camtarget ()
⇒ v =
0 0 0
</pre></div>
<p>We can turn the camera to point at a new target:
</p>
<div class="example">
<pre class="example">camtarget ([1 1 1])
camtarget ()
⇒ 1 1 1
</pre></div>
<p>Having done so, the camera target <var>mode</var> is manual:
</p>
<div class="example">
<pre class="example">camtarget ("mode")
⇒ manual
</pre></div>
<p>This means, for example, adding new objects to the scene will not retarget
the camera:
</p>
<div class="example">
<pre class="example">hold on;
peaks ()
camtarget ()
⇒ 1 1 1
</pre></div>
<p>We can reset it to be automatic:
</p>
<div class="example">
<pre class="example">camtarget ("auto")
camtarget ()
⇒ 0 0 0.76426
close (hf)
</pre></div>
<p>By default, these commands affect the current axis; alternatively, an axis
can be specified by the optional argument <var>ax</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcampos">campos</a>, <a href="#XREFcamup">camup</a>, <a href="#XREFcamva">camva</a>.
</p></dd></dl>
<span id="XREFcamup"></span><dl>
<dt id="index-camup">: <em><var>up</var> =</em> <strong>camup</strong> <em>()</em></dt>
<dt id="index-camup-1">: <em></em> <strong>camup</strong> <em>([<var>x</var> <var>y</var> <var>z</var>])</em></dt>
<dt id="index-camup-2">: <em><var>mode</var> =</em> <strong>camup</strong> <em>("mode")</em></dt>
<dt id="index-camup-3">: <em></em> <strong>camup</strong> <em>(<var>mode</var>)</em></dt>
<dt id="index-camup-4">: <em></em> <strong>camup</strong> <em>(<var>ax</var>, …)</em></dt>
<dd><p>Set or get the camera up vector.
</p>
<p>By default, the camera is oriented so that “up” corresponds to the
positive z-axis:
</p>
<div class="example">
<pre class="example">hf = figure ();
sphere (36)
v = camup ()
⇒ v =
0 0 1
</pre></div>
<p>Specifying a new “up vector” rolls the camera and sets the mode to manual:
</p>
<div class="example">
<pre class="example">camup ([1 1 0])
camup ()
⇒ 1 1 0
camup ("mode")
⇒ manual
</pre></div>
<p>Modifying the up vector does not modify the camera target
(see <a href="#XREFcamtarget">camtarget</a>). Thus, the camera up vector might not be
orthogonal to the direction of the camera’s view:
</p>
<div class="example">
<pre class="example">camup ([1 2 3])
dot (camup (), camtarget () - campos ())
⇒ 6...
</pre></div>
<p>A consequence is that “pulling back” on the up vector does not pitch the
camera view (as that would require changing the target). Setting the up
vector is thus typically used only to roll the camera. A more intuitive
command for this purpose is <a href="#XREFcamroll">camroll</a>.
</p>
<p>Finally, we can reset the up vector to automatic mode:
</p>
<div class="example">
<pre class="example">camup ("auto")
camup ()
⇒ 0 0 1
close (hf)
</pre></div>
<p>By default, these commands affect the current axis; alternatively, an axis
can be specified by the optional argument <var>ax</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcampos">campos</a>, <a href="#XREFcamtarget">camtarget</a>, <a href="#XREFcamva">camva</a>.
</p></dd></dl>
<span id="XREFcamva"></span><dl>
<dt id="index-camva">: <em><var>a</var> =</em> <strong>camva</strong> <em>()</em></dt>
<dt id="index-camva-1">: <em></em> <strong>camva</strong> <em>(<var>a</var>)</em></dt>
<dt id="index-camva-2">: <em><var>mode</var> =</em> <strong>camva</strong> <em>("mode")</em></dt>
<dt id="index-camva-3">: <em></em> <strong>camva</strong> <em>(<var>mode</var>)</em></dt>
<dt id="index-camva-4">: <em></em> <strong>camva</strong> <em>(<var>ax</var>, …)</em></dt>
<dd><p>Set or get the camera viewing angle.
</p>
<p>The camera has a viewing angle which determines how much can be seen. By
default this is:
</p>
<div class="example">
<pre class="example">hf = figure();
sphere (36)
a = camva ()
⇒ a = 10.340
</pre></div>
<p>To get a wider-angle view, we could double the viewing angle. This will
also set the mode to manual:
</p>
<div class="example">
<pre class="example">camva (2*a)
camva ("mode")
⇒ manual
</pre></div>
<p>We can set it back to automatic:
</p>
<div class="example">
<pre class="example">camva ("auto")
camva ("mode")
⇒ auto
camva ()
⇒ ans = 10.340
close (hf)
</pre></div>
<p>By default, these commands affect the current axis; alternatively, an axis
can be specified by the optional argument <var>ax</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcampos">campos</a>, <a href="#XREFcamtarget">camtarget</a>, <a href="#XREFcamup">camup</a>.
</p></dd></dl>
<span id="XREFcamzoom"></span><dl>
<dt id="index-camzoom">: <em></em> <strong>camzoom</strong> <em>(<var>zf</var>)</em></dt>
<dt id="index-camzoom-1">: <em></em> <strong>camzoom</strong> <em>(<var>ax</var>, <var>zf</var>)</em></dt>
<dd><p>Zoom the camera in or out.
</p>
<p>A value of <var>zf</var> larger than 1 “zooms in” such that the scene appears
magnified:
</p>
<div class="example">
<pre class="example">hf = figure ();
sphere (36)
camzoom (1.2)
</pre></div>
<p>A value smaller than 1 “zooms out” so the camera can see more of the
scene:
</p>
<div class="example">
<pre class="example">camzoom (0.5)
</pre></div>
<p>Technically speaking, zooming affects the “viewing angle”. The following
command resets to the default zoom:
</p>
<div class="example">
<pre class="example">camva ("auto")
close (hf)
</pre></div>
<p>By default, these commands affect the current axis; alternatively, an axis
can be specified by the optional argument <var>ax</var>.
</p>
<p><strong>See also:</strong> <a href="#XREFcamroll">camroll</a>, <a href="#XREFcamorbit">camorbit</a>, <a href="#XREFcamlookat">camlookat</a>, <a href="#XREFcamva">camva</a>.
</p></dd></dl>
<span id="XREFslice"></span><dl>
<dt id="index-slice">: <em></em> <strong>slice</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>v</var>, <var>sx</var>, <var>sy</var>, <var>sz</var>)</em></dt>
<dt id="index-slice-1">: <em></em> <strong>slice</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>v</var>, <var>xi</var>, <var>yi</var>, <var>zi</var>)</em></dt>
<dt id="index-slice-2">: <em></em> <strong>slice</strong> <em>(<var>v</var>, <var>sx</var>, <var>sy</var>, <var>sz</var>)</em></dt>
<dt id="index-slice-3">: <em></em> <strong>slice</strong> <em>(<var>v</var>, <var>xi</var>, <var>yi</var>, <var>zi</var>)</em></dt>
<dt id="index-slice-4">: <em></em> <strong>slice</strong> <em>(…, <var>method</var>)</em></dt>
<dt id="index-slice-5">: <em></em> <strong>slice</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-slice-6">: <em><var>h</var> =</em> <strong>slice</strong> <em>(…)</em></dt>
<dd><p>Plot slices of 3-D data/scalar fields.
</p>
<p>Each element of the 3-dimensional array <var>v</var> represents a scalar value at
a location given by the parameters <var>x</var>, <var>y</var>, and <var>z</var>. The
parameters <var>x</var>, <var>x</var>, and <var>z</var> are either 3-dimensional arrays of
the same size as the array <var>v</var> in the <code>"meshgrid"</code> format or
vectors. The parameters <var>xi</var>, etc. respect a similar format to
<var>x</var>, etc., and they represent the points at which the array <var>vi</var>
is interpolated using interp3. The vectors <var>sx</var>, <var>sy</var>, and
<var>sz</var> contain points of orthogonal slices of the respective axes.
</p>
<p>If <var>x</var>, <var>y</var>, <var>z</var> are omitted, they are assumed to be
<code>x = 1:size (<var>v</var>, 2)</code>, <code>y = 1:size (<var>v</var>, 1)</code> and
<code>z = 1:size (<var>v</var>, 3)</code>.
</p>
<p><var>method</var> is one of:
</p>
<dl compact="compact">
<dt><code>"nearest"</code></dt>
<dd><p>Return the nearest neighbor.
</p>
</dd>
<dt><code>"linear"</code></dt>
<dd><p>Linear interpolation from nearest neighbors.
</p>
</dd>
<dt><code>"cubic"</code></dt>
<dd><p>Cubic interpolation from four nearest neighbors (not implemented yet).
</p>
</dd>
<dt><code>"spline"</code></dt>
<dd><p>Cubic spline interpolation—smooth first and second derivatives
throughout the curve.
</p></dd>
</dl>
<p>The default method is <code>"linear"</code>.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p>The optional return value <var>h</var> is a graphics handle to the created
surface object.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">[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);
</pre></div>
<p><strong>See also:</strong> <a href="Multi_002ddimensional-Interpolation.html#XREFinterp3">interp3</a>, <a href="Graphics-Objects.html#XREFsurface">surface</a>, <a href="Two_002dDimensional-Plots.html#XREFpcolor">pcolor</a>.
</p></dd></dl>
<span id="XREFribbon"></span><dl>
<dt id="index-ribbon">: <em></em> <strong>ribbon</strong> <em>(<var>y</var>)</em></dt>
<dt id="index-ribbon-1">: <em></em> <strong>ribbon</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dt id="index-ribbon-2">: <em></em> <strong>ribbon</strong> <em>(<var>x</var>, <var>y</var>, <var>width</var>)</em></dt>
<dt id="index-ribbon-3">: <em></em> <strong>ribbon</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-ribbon-4">: <em><var>h</var> =</em> <strong>ribbon</strong> <em>(…)</em></dt>
<dd><p>Draw a ribbon plot for the columns of <var>y</var> vs. <var>x</var>.
</p>
<p>If <var>x</var> is omitted, a vector containing the row numbers is assumed
(<code>1:rows (Y)</code>). Alternatively, <var>x</var> can also be a vector with
same number of elements as rows of <var>y</var> in which case the same
<var>x</var> is used for each column of <var>y</var>.
</p>
<p>The optional parameter <var>width</var> specifies the width of a single ribbon
(default is 0.75).
</p>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p>The optional return value <var>h</var> is a vector of graphics handles to
the surface objects representing each ribbon.
</p>
<p><strong>See also:</strong> <a href="Graphics-Objects.html#XREFsurface">surface</a>, <a href="#XREFwaterfall">waterfall</a>.
</p></dd></dl>
<span id="XREFshading"></span><dl>
<dt id="index-shading">: <em></em> <strong>shading</strong> <em>(<var>type</var>)</em></dt>
<dt id="index-shading-1">: <em></em> <strong>shading</strong> <em>(<var>hax</var>, <var>type</var>)</em></dt>
<dd><p>Set the shading of patch or surface graphic objects.
</p>
<p>Valid arguments for <var>type</var> are
</p>
<dl compact="compact">
<dt><code>"flat"</code></dt>
<dd><p>Single colored patches with invisible edges.
</p>
</dd>
<dt><code>"faceted"</code></dt>
<dd><p>Single colored patches with black edges.
</p>
</dd>
<dt><code>"interp"</code></dt>
<dd><p>Colors between patch vertices are interpolated and the patch edges are
invisible.
</p></dd>
</dl>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p><strong>See also:</strong> <a href="Two_002dDimensional-Plots.html#XREFfill">fill</a>, <a href="#XREFmesh">mesh</a>, <a href="Graphics-Objects.html#XREFpatch">patch</a>, <a href="Two_002dDimensional-Plots.html#XREFpcolor">pcolor</a>, <a href="#XREFsurf">surf</a>, <a href="Graphics-Objects.html#XREFsurface">surface</a>, <a href="#XREFhidden">hidden</a>, <a href="#XREFlighting">lighting</a>.
</p></dd></dl>
<span id="XREFscatter3"></span><dl>
<dt id="index-scatter3">: <em></em> <strong>scatter3</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>)</em></dt>
<dt id="index-scatter3-1">: <em></em> <strong>scatter3</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>s</var>)</em></dt>
<dt id="index-scatter3-2">: <em></em> <strong>scatter3</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>, <var>s</var>, <var>c</var>)</em></dt>
<dt id="index-scatter3-3">: <em></em> <strong>scatter3</strong> <em>(…, <var>style</var>)</em></dt>
<dt id="index-scatter3-4">: <em></em> <strong>scatter3</strong> <em>(…, "filled")</em></dt>
<dt id="index-scatter3-5">: <em></em> <strong>scatter3</strong> <em>(…, <var>prop</var>, <var>val</var>)</em></dt>
<dt id="index-scatter3-6">: <em></em> <strong>scatter3</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-scatter3-7">: <em><var>h</var> =</em> <strong>scatter3</strong> <em>(…)</em></dt>
<dd><p>Draw a 3-D scatter plot.
</p>
<p>A marker is plotted at each point defined by the coordinates in the vectors
<var>x</var>, <var>y</var>, and <var>z</var>.
</p>
<p>The size of the markers is determined by <var>s</var>, which can be a scalar
or a vector of the same length as <var>x</var>, <var>y</var>, and <var>z</var>. If <var>s</var>
is not given, or is an empty matrix, then a default value of 8 points is
used.
</p>
<p>The color of the markers is determined by <var>c</var>, 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 <var>x</var> that gives
a scaled index into the current colormap; or an Nx3 matrix
defining the RGB color of each marker individually.
</p>
<p>The marker to use can be changed with the <var>style</var> argument, that is a
string defining a marker in the same manner as the <code>plot</code> command.
If no marker is specified it defaults to <code>"o"</code> or circles.
If the argument <code>"filled"</code> is given then the markers are filled.
</p>
<p>Additional property/value pairs are passed directly to the underlying
patch object. The full list of properties is documented at
<a href="Patch-Properties.html">Patch Properties</a>.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p>The optional return value <var>h</var> is a graphics handle to the hggroup
object representing the points.
</p>
<div class="example">
<pre class="example">[x, y, z] = peaks (20);
scatter3 (x(:), y(:), z(:), [], z(:));
</pre></div>
<p><strong>See also:</strong> <a href="Two_002dDimensional-Plots.html#XREFscatter">scatter</a>, <a href="Graphics-Objects.html#XREFpatch">patch</a>, <a href="Two_002dDimensional-Plots.html#XREFplot">plot</a>.
</p></dd></dl>
<span id="XREFwaterfall"></span><dl>
<dt id="index-waterfall">: <em></em> <strong>waterfall</strong> <em>(<var>x</var>, <var>y</var>, <var>z</var>)</em></dt>
<dt id="index-waterfall-1">: <em></em> <strong>waterfall</strong> <em>(<var>z</var>)</em></dt>
<dt id="index-waterfall-2">: <em></em> <strong>waterfall</strong> <em>(…, <var>c</var>)</em></dt>
<dt id="index-waterfall-3">: <em></em> <strong>waterfall</strong> <em>(…, <var>prop</var>, <var>val</var>, …)</em></dt>
<dt id="index-waterfall-4">: <em></em> <strong>waterfall</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-waterfall-5">: <em><var>h</var> =</em> <strong>waterfall</strong> <em>(…)</em></dt>
<dd><p>Plot a 3-D waterfall plot.
</p>
<p>A waterfall plot is similar to a <code>meshz</code> plot except only
mesh lines for the rows of <var>z</var> (x-values) are shown.
</p>
<p>The wireframe mesh is plotted using rectangles. The vertices of the
rectangles [<var>x</var>, <var>y</var>] are typically the output of <code>meshgrid</code>.
over a 2-D rectangular region in the x-y plane. <var>z</var> determines the
height above the plane of each vertex. If only a single <var>z</var> matrix is
given, then it is plotted over the meshgrid
<code><var>x</var> = 1:columns (<var>z</var>), <var>y</var> = 1:rows (<var>z</var>)</code>.
Thus, columns of <var>z</var> correspond to different <var>x</var> values and rows
of <var>z</var> correspond to different <var>y</var> values.
</p>
<p>The color of the mesh is computed by linearly scaling the <var>z</var> values
to fit the range of the current colormap. Use <code>caxis</code> and/or
change the colormap to control the appearance.
</p>
<p>Optionally the color of the mesh can be specified independently of <var>z</var>
by supplying a color matrix, <var>c</var>.
</p>
<p>Any property/value pairs are passed directly to the underlying surface
object. The full list of properties is documented at
<a href="Surface-Properties.html">Surface Properties</a>.
</p>
<p>If the first argument <var>hax</var> is an axes handle, then plot into this axes,
rather than the current axes returned by <code>gca</code>.
</p>
<p>The optional return value <var>h</var> is a graphics handle to the created
surface object.
</p>
<p><strong>See also:</strong> <a href="#XREFmeshz">meshz</a>, <a href="#XREFmesh">mesh</a>, <a href="#XREFmeshc">meshc</a>, <a href="Two_002dDimensional-Plots.html#XREFcontour">contour</a>, <a href="#XREFsurf">surf</a>, <a href="Graphics-Objects.html#XREFsurface">surface</a>, <a href="#XREFribbon">ribbon</a>, <a href="#XREFmeshgrid">meshgrid</a>, <a href="#XREFhidden">hidden</a>, <a href="#XREFshading">shading</a>, <a href="Representing-Images.html#XREFcolormap">colormap</a>, <a href="Axis-Configuration.html#XREFcaxis">caxis</a>.
</p></dd></dl>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="Aspect-Ratio.html" accesskey="1">Aspect Ratio</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="Three_002ddimensional-Function-Plotting.html" accesskey="2">Three-dimensional Function Plotting</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="Three_002ddimensional-Geometric-Shapes.html" accesskey="3">Three-dimensional Geometric Shapes</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<div class="header">
<p>
Next: <a href="Plot-Annotations.html" accesskey="n" rel="next">Plot Annotations</a>, Previous: <a href="Two_002dDimensional-Plots.html" accesskey="p" rel="prev">Two-Dimensional Plots</a>, Up: <a href="High_002dLevel-Plotting.html" accesskey="u" rel="up">High-Level Plotting</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|