General purpose functions¶
The general purpose functions are used for managing variables and workspace, control of output, etc. The functions listed here are a subset of the general purpose functions described in the MATLAB manual. The functions can be divided into the following groups:
help |
Online documentation |
type |
List file |
what |
Directory listing of .m-files, .mat-files and .mex-files |
… |
Continuation |
% |
Write a comment line |
clear |
Remove variables from workspace |
disp |
Display a variable in matrix bank on display screen |
load |
Retrieve variable from disk and load in workspace |
save |
Save workspace variables on disk |
who, whos |
List directory of variables in matrix bank |
diary |
Save session in a disk file |
echo |
Control output on the display screen |
format |
Control the output display format |
quit |
Terminate CALFEM session |
General functions¶
help¶
- Purpose:
Display a description of purpose and syntax for a specific function.
- Syntax:
help function_name- Description:
helpprovides an online documentation for the specified function.- Example:
Typing
>> help spring1eyields
Ke=spring1e(ep) ------------------------------------------------------------- PURPOSE Compute element stiffness matrix for spring (analog) element. INPUT: ep = [k]; spring stiffness or analog quantity. OUTPUT: Ke : stiffness matrix, dim(Ke)= 2 x 2 -------------------------------------------------------------
Note
This is a MATLAB built-in function. For more information about the help function, type help help.
type¶
- Purpose:
List file.
- Syntax:
type filename- Description:
type filenamelists the specified file. Use path names in the usual way for your operating system. If a filename extension is not given,.mis added by default. This makes it convenient to list the contents of.m-files on the screen.
Note
This is a MATLAB built-in function. For more information about the type function, type help type.
what¶
- Purpose:
Directory listing of
.m-files,.mat-files andmex-files.- Syntax:
what what dirname- Description:
whatlists the.m-files,.mat-files and.mex-files in the current directory.what dirnamelists the files in directorydirnamein the MATLAB search path. The syntax of the path depends on your operating system.
Note
This is a MATLAB built-in function. For more information about the what function, type help what.
…¶
- Purpose:
Continuation.
- Syntax:
...- Description:
An expression can be continued on the next line by using
....
Note
This is a MATLAB built-in function.
%¶
- Purpose:
Write a comment line.
- Syntax:
% arbitrary text- Description:
An arbitrary text can be written after the symbol
%.
Note
This is a MATLAB built-in character.
Variables and workspace¶
clear¶
- Purpose:
Remove variables from workspace.
- Syntax:
clear clear name1 name2 name3 ...- Description:
clearremoves all variables from workspace.clear name1 name2 name3 ...removes specified variables from workspace.
Note
This is a MATLAB built-in function. For more information about the clear function, type help clear.
disp¶
- Purpose:
Display a variable in matrix bank on display screen.
- Syntax:
disp(A)- Description:
disp(A)displays the matrixAon the display screen.
Note
This is a MATLAB built-in function. For more information about the disp function, type help disp.
load¶
- Purpose:
Retrieve variable from disk and load in workspace.
- Syntax:
load filename load filename.ext- Description:
load filenameretrieves the variables from the binary filefilename.mat.load filename.extreads the ASCII filefilename.extwith numeric data arranged in \(m\) rows and \(n\) columns. The result is an \(m \times n\) matrix residing in workspace with the namefilename, i.e. with the extension stripped.
Note
This is a MATLAB built-in function. For more information about the load function, type help load.
save¶
- Purpose:
Save workspace variables on disk.
- Syntax:
save filename save filename variables save filename variables -ascii- Description:
save filenamewrites all variables residing in workspace in a binary file namedfilename.mat.save filename variableswrites named variables, separated by blanks, in a binary file namedfilename.mat.save filename variables -asciiwrites named variables in an ASCII file namedfilename.
Note
This is a MATLAB built-in function. For more information about the save function, type help save.
who, whos¶
- Purpose:
List directory of variables in matrix bank.
- Syntax:
who whos- Description:
wholists the variables currently in memory.whoslists the current variables and their size.- Examples:
who Your variables are: A B C K M X k lambdawhos Name Size Bytes Class Attributes A 3x3 72 double B 3x3 72 double C 3x3 72 double K 20x20 3200 double M 20x20 3200 double X 20x20 3200 double k 1x1 8 double lambda 20x1 160 double
Note
These are MATLAB built-in functions. For more information about the functions, type help who or help whos.
Files and command window¶
diary¶
- Purpose:
Save session in a disk file.
- Syntax:
diary filename diary off diary on- Description:
diary filenamewrites a copy of all subsequent keyboard input and most of the resulting output (but not graphs) on the named file. If the filefilenamealready exists, the output is appended to the end of that file.diary offstops storage of the output.diary onturns it back on again, using the current filename or default filenamediaryif none has yet been specified.The
diaryfunction may be used to store the current session for later runs. To make this possible, finish each command line with semicolon ‘;’ to avoid the storage of intermediate results on the named diary file.
Note
This is a MATLAB built-in function. For more information about the diary function, type help diary.
echo¶
- Purpose:
Control output on the display screen.
- Syntax:
echo on echo off echo- Description:
echo onturns on echoing of commands inside Script-files.echo offturns off echoing.echoby itself toggles the echo state.
Note
This is a MATLAB built-in function. For more information about the echo function, type help echo.
format¶
- Purpose:
Control the output display format.
- Syntax:
See the listing below.
- Description:
formatcontrols the output format. By default, MATLAB displays numbers in a short format with five decimal digits.
Command |
Result |
Example |
|---|---|---|
|
5 digit scaled fix point |
|
|
16 digit scaled fix point |
|
|
5 digit floating point |
|
|
16 digit floating point |
|
Note
This is a MATLAB built-in function. For more information about the format function, type help format.
quit¶
- Purpose:
Terminate CALFEM session.
- Syntax:
quit- Description:
quitterminates CALFEM without saving the workspace.
Note
This is a MATLAB built-in function. For more information about the quit function, type help quit.