type
Display contents of file
Syntax
Description
Examples
View File Contents
Display the contents of the file diceRoll
. Since diceRoll
does not exist, but diceRoll.m
does exist, MATLAB displays the contents of diceRoll.m
.
type diceRoll
function [d1,d2] = diceRoll str = '@()randi([1 6],1)'; d1 = str2func(str); d2 = eval(str); end function r = randi(~,~) r = 1; end
Input Arguments
filename
— File name
character vector | string
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 file
myscript.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
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced in R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)