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
|
<!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>Status of Variables (GNU Octave (version 6.2.0))</title>
<meta name="description" content="Status of Variables (GNU Octave (version 6.2.0))">
<meta name="keywords" content="Status of Variables (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="Variables.html" rel="up" title="Variables">
<link href="Expressions.html" rel="next" title="Expressions">
<link href="Persistent-Variables.html" rel="prev" title="Persistent Variables">
<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="Status-of-Variables"></span><div class="header">
<p>
Previous: <a href="Persistent-Variables.html" accesskey="p" rel="prev">Persistent Variables</a>, Up: <a href="Variables.html" accesskey="u" rel="up">Variables</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="Status-of-Variables-1"></span><h3 class="section">7.3 Status of Variables</h3>
<p>When creating simple one-shot programs it can be very convenient to
see which variables are available at the prompt. The function <code>who</code>
and its siblings <code>whos</code> and <code>whos_line_format</code> will show
different information about what is in memory, as the following shows.
</p>
<div class="example">
<pre class="example">str = "A random string";
who
-| Variables in the current scope:
-|
-| ans str
</pre></div>
<span id="XREFwho"></span><dl>
<dt id="index-who">: <em></em> <strong>who</strong></dt>
<dt id="index-who-1">: <em></em> <strong>who</strong> <em>pattern …</em></dt>
<dt id="index-who-2">: <em></em> <strong>who</strong> <em>option pattern …</em></dt>
<dt id="index-who-3">: <em>C =</em> <strong>who</strong> <em>("pattern", …)</em></dt>
<dd><p>List currently defined variables matching the given patterns.
</p>
<p>Valid pattern syntax is the same as described for the <code>clear</code> command.
If no patterns are supplied, all variables are listed.
</p>
<p>By default, only variables visible in the local scope are displayed.
</p>
<p>The following are valid options, but may not be combined.
</p>
<dl compact="compact">
<dt><code>global</code></dt>
<dd><p>List variables in the global scope rather than the current scope.
</p>
</dd>
<dt><code>-regexp</code></dt>
<dd><p>The patterns are considered to be regular expressions when matching the
variables to display. The same pattern syntax accepted by the <code>regexp</code>
function is used.
</p>
</dd>
<dt><code>-file</code></dt>
<dd><p>The next argument is treated as a filename. All variables found within the
specified file are listed. No patterns are accepted when reading variables
from a file.
</p></dd>
</dl>
<p>If called as a function, return a cell array of defined variable names
matching the given patterns.
</p>
<p><strong>See also:</strong> <a href="#XREFwhos">whos</a>, <a href="Global-Variables.html#XREFisglobal">isglobal</a>, <a href="Variables.html#XREFisvarname">isvarname</a>, <a href="#XREFexist">exist</a>, <a href="Manipulating-Strings.html#XREFregexp">regexp</a>.
</p></dd></dl>
<span id="XREFwhos"></span><dl>
<dt id="index-whos">: <em></em> <strong>whos</strong></dt>
<dt id="index-whos-1">: <em></em> <strong>whos</strong> <em>pattern …</em></dt>
<dt id="index-whos-2">: <em></em> <strong>whos</strong> <em>option pattern …</em></dt>
<dt id="index-whos-3">: <em>S =</em> <strong>whos</strong> <em>("pattern", …)</em></dt>
<dd><p>Provide detailed information on currently defined variables matching the
given patterns.
</p>
<p>Options and pattern syntax are the same as for the <code>who</code> command.
</p>
<p>Extended information about each variable is summarized in a table with the
following default entries.
</p>
<dl compact="compact">
<dt>Attr</dt>
<dd><p>Attributes of the listed variable. Possible attributes are:
</p>
<dl compact="compact">
<dt>blank</dt>
<dd><p>Variable in local scope
</p>
</dd>
<dt><code>c</code></dt>
<dd><p>Variable of complex type.
</p>
</dd>
<dt><code>f</code></dt>
<dd><p>Formal parameter (function argument).
</p>
</dd>
<dt><code>g</code></dt>
<dd><p>Variable with global scope.
</p>
</dd>
<dt><code>p</code></dt>
<dd><p>Persistent variable.
</p></dd>
</dl>
</dd>
<dt>Name</dt>
<dd><p>The name of the variable.
</p>
</dd>
<dt>Size</dt>
<dd><p>The logical size of the variable. A scalar is 1x1, a vector is
1xN or Nx1, a 2-D matrix is MxN.
</p>
</dd>
<dt>Bytes</dt>
<dd><p>The amount of memory currently used to store the variable.
</p>
</dd>
<dt>Class</dt>
<dd><p>The class of the variable. Examples include double, single, char, uint16,
cell, and struct.
</p></dd>
</dl>
<p>The table can be customized to display more or less information through
the function <code>whos_line_format</code>.
</p>
<p>If <code>whos</code> is called as a function, return a struct array of defined
variable names matching the given patterns. Fields in the structure
describing each variable are: name, size, bytes, class, global, sparse,
complex, nesting, persistent.
</p>
<p><strong>See also:</strong> <a href="#XREFwho">who</a>, <a href="#XREFwhos_005fline_005fformat">whos_line_format</a>.
</p></dd></dl>
<span id="XREFwhos_005fline_005fformat"></span><dl>
<dt id="index-whos_005fline_005fformat">: <em><var>val</var> =</em> <strong>whos_line_format</strong> <em>()</em></dt>
<dt id="index-whos_005fline_005fformat-1">: <em><var>old_val</var> =</em> <strong>whos_line_format</strong> <em>(<var>new_val</var>)</em></dt>
<dt id="index-whos_005fline_005fformat-2">: <em></em> <strong>whos_line_format</strong> <em>(<var>new_val</var>, "local")</em></dt>
<dd><p>Query or set the format string used by the command <code>whos</code>.
</p>
<p>A full format string is:
</p>
<div class="example">
<pre class="example">%[modifier]<command>[:width[:left-min[:balance]]];
</pre></div>
<p>The following command sequences are available:
</p>
<dl compact="compact">
<dt><code>%a</code></dt>
<dd><p>Prints attributes of variables (g=global, p=persistent, f=formal parameter).
</p>
</dd>
<dt><code>%b</code></dt>
<dd><p>Prints number of bytes occupied by variables.
</p>
</dd>
<dt><code>%c</code></dt>
<dd><p>Prints class names of variables.
</p>
</dd>
<dt><code>%e</code></dt>
<dd><p>Prints elements held by variables.
</p>
</dd>
<dt><code>%n</code></dt>
<dd><p>Prints variable names.
</p>
</dd>
<dt><code>%s</code></dt>
<dd><p>Prints dimensions of variables.
</p>
</dd>
<dt><code>%t</code></dt>
<dd><p>Prints type names of variables.
</p></dd>
</dl>
<p>Every command may also have an alignment modifier:
</p>
<dl compact="compact">
<dt><code>l</code></dt>
<dd><p>Left alignment.
</p>
</dd>
<dt><code>r</code></dt>
<dd><p>Right alignment (default).
</p>
</dd>
<dt><code>c</code></dt>
<dd><p>Column-aligned (only applicable to command %s).
</p></dd>
</dl>
<p>The <code>width</code> parameter is a positive integer specifying the minimum
number of columns used for printing. No maximum is needed as the field will
auto-expand as required.
</p>
<p>The parameters <code>left-min</code> and <code>balance</code> are only available when
the column-aligned modifier is used with the command ‘<samp>%s</samp>’.
<code>balance</code> specifies the column number within the field width which
will be aligned between entries. Numbering starts from 0 which indicates
the leftmost column. <code>left-min</code> specifies the minimum field width to
the left of the specified balance column.
</p>
<p>The default format is:
</p>
<p><code>" %a:4; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;\n"</code>
</p>
<p>When called from inside a function with the <code>"local"</code> option, the
variable is changed locally for the function and any subroutines it calls.
The original variable value is restored when exiting the function.
</p>
<p><strong>See also:</strong> <a href="#XREFwhos">whos</a>.
</p></dd></dl>
<p>Instead of displaying which variables are in memory, it is possible
to determine if a given variable is available. That way it is possible
to alter the behavior of a program depending on the existence of a
variable. The following example illustrates this.
</p>
<div class="example">
<pre class="example">if (! exist ("meaning", "var"))
disp ("The program has no 'meaning'");
endif
</pre></div>
<span id="XREFexist"></span><dl>
<dt id="index-exist">: <em><var>c</var> =</em> <strong>exist</strong> <em>(<var>name</var>)</em></dt>
<dt id="index-exist-1">: <em><var>c</var> =</em> <strong>exist</strong> <em>(<var>name</var>, <var>type</var>)</em></dt>
<dd><p>Check for the existence of <var>name</var> as a variable, function, file, directory,
or class.
</p>
<p>The return code <var>c</var> is one of
</p>
<dl compact="compact">
<dt>1</dt>
<dd><p><var>name</var> is a variable.
</p>
</dd>
<dt>2</dt>
<dd><p><var>name</var> is an absolute filename, an ordinary file in Octave’s <code>path</code>,
or (after appending ‘<samp>.m</samp>’) a function file in Octave’s <code>path</code>.
</p>
</dd>
<dt>3</dt>
<dd><p><var>name</var> is a ‘<samp>.oct</samp>’ or ‘<samp>.mex</samp>’ file in Octave’s <code>path</code>.
</p>
</dd>
<dt>5</dt>
<dd><p><var>name</var> is a built-in function.
</p>
</dd>
<dt>7</dt>
<dd><p><var>name</var> is a directory.
</p>
</dd>
<dt>8</dt>
<dd><p><var>name</var> is a class. (Note: not currently implemented)
</p>
</dd>
<dt>103</dt>
<dd><p><var>name</var> is a function not associated with a file (entered on the command
line).
</p>
</dd>
<dt>0</dt>
<dd><p><var>name</var> does not exist.
</p></dd>
</dl>
<p>If the optional argument <var>type</var> is supplied, check only for symbols of the
specified type. Valid types are
</p>
<dl compact="compact">
<dt><code>"var"</code></dt>
<dd><p>Check only for variables.
</p>
</dd>
<dt><code>"builtin"</code></dt>
<dd><p>Check only for built-in functions.
</p>
</dd>
<dt><code>"dir"</code></dt>
<dd><p>Check only for directories.
</p>
</dd>
<dt><code>"file"</code></dt>
<dd><p>Check only for files and directories.
</p>
</dd>
<dt><code>"class"</code></dt>
<dd><p>Check only for classes. (Note: This option is accepted, but not currently
implemented)
</p></dd>
</dl>
<p>If no type is given, and there are multiple possible matches for name,
<code>exist</code> will return a code according to the following priority list:
variable, built-in function, oct-file, directory, file, class.
</p>
<p><code>exist</code> returns 2 if a regular file called <var>name</var> is present in
Octave’s search path. For information about other types of files not on the
search path use some combination of the functions <code>file_in_path</code> and
<code>stat</code> instead.
</p>
<p>Programming Note: If <var>name</var> is implemented by a buggy .oct/.mex file,
calling <var>exist</var> may cause Octave to crash. To maintain high performance,
Octave trusts .oct/.mex files instead of sandboxing them.
</p>
<p><strong>See also:</strong> <a href="Manipulating-the-Load-Path.html#XREFfile_005fin_005floadpath">file_in_loadpath</a>, <a href="Filesystem-Utilities.html#XREFfile_005fin_005fpath">file_in_path</a>, <a href="Manipulating-the-Load-Path.html#XREFdir_005fin_005floadpath">dir_in_loadpath</a>, <a href="Filesystem-Utilities.html#XREFstat">stat</a>.
</p></dd></dl>
<p>Usually Octave will manage the memory, but sometimes it can be practical
to remove variables from memory manually. This is usually needed when
working with large variables that fill a substantial part of the memory.
On a computer that uses the IEEE floating point format, the following
program allocates a matrix that requires around 128 MB memory.
</p>
<div class="example">
<pre class="example">large_matrix = zeros (4000, 4000);
</pre></div>
<p>Since having this variable in memory might slow down other computations,
it can be necessary to remove it manually from memory. The <code>clear</code>
or <code>clearvars</code> functions do this.
</p>
<span id="XREFclear"></span><dl>
<dt id="index-clear">: <em></em> <strong>clear</strong></dt>
<dt id="index-clear-1">: <em></em> <strong>clear</strong> <em><var>pattern</var> …</em></dt>
<dt id="index-clear-2">: <em></em> <strong>clear</strong> <em><var>options</var> <var>pattern</var> …</em></dt>
<dd><p>Delete the names matching the given <var>pattern</var>s thereby freeing memory.
</p>
<p>The <var>pattern</var> may contain the following special characters:
</p>
<dl compact="compact">
<dt><code>?</code></dt>
<dd><p>Match any single character.
</p>
</dd>
<dt><code>*</code></dt>
<dd><p>Match zero or more characters.
</p>
</dd>
<dt><code>[ <var>list</var> ]</code></dt>
<dd><p>Match the list of characters specified by <var>list</var>. If the first character
is <code>!</code> or <code>^</code>, match all characters except those specified by
<var>list</var>. For example, the pattern <code>[a-zA-Z]</code> will match all lowercase
and uppercase alphabetic characters.
</p></dd>
</dl>
<p>For example, the command
</p>
<div class="example">
<pre class="example">clear foo b*r
</pre></div>
<p>clears the name <code>foo</code> and all names that begin with the letter ‘<samp>b</samp>’
and end with the letter ‘<samp>r</samp>’.
</p>
<p>If <code>clear</code> is called without any arguments, all user-defined variables
are cleared from the current workspace (i.e., local variables). Any global
variables present will no longer be visible in the current workspace, but they
will continue to exist in the global workspace. Functions are unaffected by
this form of <code>clear</code>.
</p>
<p>The following options are available in both long and short form
</p>
<dl compact="compact">
<dt><code>all, -all, -a</code></dt>
<dd><p>Clear all local and global user-defined variables, and all functions from the
symbol table.
</p>
</dd>
<dt><code>-exclusive, -x</code></dt>
<dd><p>Clear variables that do <strong>not</strong> match the following pattern.
</p>
</dd>
<dt><code>functions, -functions, -f</code></dt>
<dd><p>Clear function names from the function symbol table. Persistent variables
will be re-initialized to their default value unless the function has been
locked in memory with <code>mlock</code>.
</p>
</dd>
<dt><code>global, -global, -g</code></dt>
<dd><p>Clear global variable names.
</p>
</dd>
<dt><code>variables, -variables, -v</code></dt>
<dd><p>Clear local variable names.
</p>
</dd>
<dt><code>classes, -classes, -c</code></dt>
<dd><p>Clear the class structure table and all objects.
</p>
</dd>
<dt><code>-regexp, -r</code></dt>
<dd><p>The <var>pattern</var> arguments are treated as regular expressions and any matches
will be cleared.
</p></dd>
</dl>
<p>With the exception of <samp>-exclusive</samp> and <samp>-regexp</samp>, all long
options can be used without the dash as well. Note that, aside from
<samp>-exclusive</samp>, only one other option may appear. All options must
appear before any patterns.
</p>
<p>Programming Notes: The command <code>clear <var>name</var></code> only clears the variable
<var>name</var> when both a variable and a (shadowed) function named <var>name</var>
are currently defined. For example, suppose you have defined a function
<code>foo</code>, and then hidden it by performing the assignment <code>foo = 2</code>.
Executing the command <code>clear foo</code> once will clear the variable
definition and restore the definition of <code>foo</code> as a function.
Executing <code>clear foo</code> a second time will clear the function definition.
</p>
<p>When a local variable name, which is linked to a global variable, is cleared
only the local copy of the variable is removed. The global copy is untouched
and can be restored with <code>global <var>global_varname</var></code>. Conversely,
<code>clear -g <var>global_varname</var></code> will remove both the local and global
variables.
</p>
<p><strong>See also:</strong> <a href="#XREFclearvars">clearvars</a>, <a href="#XREFwho">who</a>, <a href="#XREFwhos">whos</a>, <a href="#XREFexist">exist</a>, <a href="Function-Locking.html#XREFmlock">mlock</a>.
</p></dd></dl>
<span id="XREFclearvars"></span><dl>
<dt id="index-clearvars">: <em></em> <strong>clearvars</strong></dt>
<dt id="index-clearvars-1">: <em></em> <strong>clearvars</strong> <em><var>pattern</var> …</em></dt>
<dt id="index-clearvars-2">: <em></em> <strong>clearvars</strong> <em>-regexp <var>pattern</var> …</em></dt>
<dt id="index-clearvars-3">: <em></em> <strong>clearvars</strong> <em>… -except <var>pattern</var> …</em></dt>
<dt id="index-clearvars-4">: <em></em> <strong>clearvars</strong> <em>… -except -regexp <var>pattern</var> …</em></dt>
<dt id="index-clearvars-5">: <em></em> <strong>clearvars</strong> <em>-global …</em></dt>
<dd><p>Delete the variables matching the given <var>pattern</var>s from memory.
</p>
<p>The <var>pattern</var> may contain the following special characters:
</p>
<dl compact="compact">
<dt><code>?</code></dt>
<dd><p>Match any single character.
</p>
</dd>
<dt><code>*</code></dt>
<dd><p>Match zero or more characters.
</p>
</dd>
<dt><code>[ <var>list</var> ]</code></dt>
<dd><p>Match the list of characters specified by <var>list</var>. If the first
character is <code>!</code> or <code>^</code>, match all characters except those
specified by <var>list</var>. For example, the pattern <code>[a-zA-Z]</code> will
match all lowercase and uppercase alphabetic characters.
</p></dd>
</dl>
<p>If the <samp>-regexp</samp> option is given then subsequent patterns are treated
as regular expressions and any matches will be cleared.
</p>
<p>If the <samp>-except</samp> option is given then subsequent patterns select
variables that will <strong>not</strong> be cleared.
</p>
<p>If the <samp>-global</samp> option is given then all patterns will be applied
to global variables rather than local variables.
</p>
<p>When called with no arguments, <code>clearvars</code> deletes all local variables.
</p>
<p>Example Code:
</p>
<p>Clear all variables starting with <code>'x'</code> and the specific variable
<code>"foobar"</code>
</p>
<div class="example">
<pre class="example">clearvars x* foobar
</pre></div>
<p>Clear the specific variable <code>"foobar"</code> and use regular expressions to
clear all variables starting with <code>'x'</code> or <code>'y'</code>.
</p>
<div class="example">
<pre class="example">clearvars foobar -regexp ^x ^y
</pre></div>
<p>Clear all variables except for <code>"foobar"</code>
</p>
<div class="example">
<pre class="example">clearvars -except foobar
</pre></div>
<p>Clear all variables beginning with <code>"foo"</code>, except for those ending
in <code>"bar"</code>
</p>
<div class="example">
<pre class="example">clearvars foo* -except -regexp bar$
</pre></div>
<p><strong>See also:</strong> <a href="#XREFclear">clear</a>, <a href="#XREFwho">who</a>, <a href="#XREFwhos">whos</a>, <a href="#XREFexist">exist</a>.
</p></dd></dl>
<span id="XREFpack"></span><dl>
<dt id="index-pack">: <em></em> <strong>pack</strong> <em>()</em></dt>
<dd><p>Consolidate workspace memory in <small>MATLAB</small>.
</p>
<p>This function is provided for compatibility, but does nothing in Octave.
</p>
<p><strong>See also:</strong> <a href="#XREFclear">clear</a>.
</p></dd></dl>
<p>Information about a function or variable such as its location in the
file system can also be acquired from within Octave. This is usually
only useful during development of programs, and not within a program.
</p>
<span id="XREFtype"></span><dl>
<dt id="index-type">: <em></em> <strong>type</strong> <em><var>name</var> …</em></dt>
<dt id="index-type-1">: <em></em> <strong>type</strong> <em>-q <var>name</var> …</em></dt>
<dt id="index-type-2">: <em>text =</em> <strong>type</strong> <em>("<var>name</var>", …)</em></dt>
<dd><p>Display the contents of <var>name</var> which may be a file, function (m-file),
variable, operator, or keyword.
</p>
<p><code>type</code> normally prepends a header line describing the category of
<var>name</var> such as function or variable; The <samp>-q</samp> option suppresses
this behavior.
</p>
<p>If no output variable is used the contents are displayed on screen.
Otherwise, a cell array of strings is returned, where each element
corresponds to the contents of each requested function.
</p></dd></dl>
<span id="XREFwhich"></span><dl>
<dt id="index-which">: <em></em> <strong>which</strong> <em>name …</em></dt>
<dd><p>Display the type of each <var>name</var>.
</p>
<p>If <var>name</var> is defined from a function file, the full name of the file is
also displayed.
</p>
<p><strong>See also:</strong> <a href="Getting-Help.html#XREFhelp">help</a>, <a href="Getting-Help.html#XREFlookfor">lookfor</a>.
</p></dd></dl>
<span id="XREFwhat"></span><dl>
<dt id="index-what">: <em></em> <strong>what</strong></dt>
<dt id="index-what-1">: <em></em> <strong>what</strong> <em><var>dir</var></em></dt>
<dt id="index-what-2">: <em>w =</em> <strong>what</strong> <em>(<var>dir</var>)</em></dt>
<dd><p>List the Octave specific files in directory <var>dir</var>.
</p>
<p>If <var>dir</var> is not specified then the current directory is used.
</p>
<p>If a return argument is requested, the files found are returned in the
structure <var>w</var>. The structure contains the following fields:
</p>
<dl compact="compact">
<dt>path</dt>
<dd><p>Full path to directory <var>dir</var>
</p>
</dd>
<dt>m</dt>
<dd><p>Cell array of m-files
</p>
</dd>
<dt>mat</dt>
<dd><p>Cell array of mat files
</p>
</dd>
<dt>mex</dt>
<dd><p>Cell array of mex files
</p>
</dd>
<dt>oct</dt>
<dd><p>Cell array of oct files
</p>
</dd>
<dt>mdl</dt>
<dd><p>Cell array of mdl files
</p>
</dd>
<dt>slx</dt>
<dd><p>Cell array of slx files
</p>
</dd>
<dt>p</dt>
<dd><p>Cell array of p-files
</p>
</dd>
<dt>classes</dt>
<dd><p>Cell array of class directories (<samp>@<var>classname</var>/</samp>)
</p>
</dd>
<dt>packages</dt>
<dd><p>Cell array of package directories (<samp>+<var>pkgname</var>/</samp>)
</p></dd>
</dl>
<p>Compatibility Note: Octave does not support mdl, slx, and p files.
<code>what</code> will always return an empty list for these categories.
</p>
<p><strong>See also:</strong> <a href="#XREFwhich">which</a>, <a href="Current-Working-Directory.html#XREFls">ls</a>, <a href="#XREFexist">exist</a>.
</p></dd></dl>
<hr>
<div class="header">
<p>
Previous: <a href="Persistent-Variables.html" accesskey="p" rel="prev">Persistent Variables</a>, Up: <a href="Variables.html" accesskey="u" rel="up">Variables</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>
|