type - Display contents of file - MATLAB (original) (raw)
Main Content
Syntax
Description
type [filename](#f9-454822-filename)
displays the contents of the specified file in the MATLAB® Command Window.
Examples
Display the contents of the file diceRoll
. Since diceRoll
does not exist, but diceRoll.m
does exist, MATLAB displays the contents of diceRoll.m
.
function [d1,d2] = diceRoll str = '@()randi([1 6],1)'; d1 = str2func(str); d2 = eval(str); end
function r = randi(,)
r = 1;
end
Input Arguments
File name to display, specified as a character vector or a string.filename
can be an absolute or relative path and can include a path and a file extension. type
supports file names with these extensions, files with any other extension are treated as plain text.
File Extension | Description |
---|---|
.mlx | MATLAB Live Script — An interactive document created using MATLAB Live Editor |
.mlapp | MATLAB App File — An app created using MATLAB App Designer |
.m | MATLAB Code — A MATLAB script, function, or class |
If you do not specify a file extension and a file without an extension does not exist, then type
assumes that the extension is .mlx
, .mlapp
, or.m
. For example, if a filemyscript.m
exists, then the command type myscript
displays the contents of that file.
type
leverages automatic character set detection to determine the file encoding for MATLAB code (.m) and other text files.
Extended Capabilities
Version History
Introduced in R2006a