Open web page or file in browser
web opens an empty MATLAB® web browser.
web( opens the page specified by
url in the MATLAB web browser. If
url is an external site,
web(url) opens the page in your system browser. If
multiple browsers are open, the page displays in the one that was most recently
the status of the operation:
stat = web(___)
0 if successful,
2 if unsuccessful. You can
include any of the input arguments in previous syntaxes.
If you do not specify any inputs to the
web function, such
[stat,h] = web, then the handle corresponds to the most
recently used MATLAB web browser.
Open the MathWorks® Web site home page in the system browser.
url = 'https://www.mathworks.com'; web(url)
View an HTML file that resides on your system.
Create an HTML file by publishing an example program file. Copy the program file to the current folder so that the code can run during the publishing process.
program = fullfile(matlabroot,'help','techdoc',... 'matlab_env','examples','fourier_demo2.m'); copyfile(program); htmlFile = publish('fourier_demo2.m');
View the file by specifying the file name.
View the file in a new instance of the browser that does not include a toolbar.
Alternatively, you can use the
file:/// URL scheme, as
long as you include the full path. The
returns the path in the
url = ['file:///',htmlFile]; web(url)
Send an email from your system browser's default mail application using the
mailto: URL scheme.
To run this example, replace the value for
email = 'email@example.com'; url = ['mailto:',email]; web(url)
View formatted text using the
text:// URL scheme.
url— Web page address or file location
Web page address or file location, specified as a character vector or a string. File locations can include an absolute or relative path.
url is an external site, then the page opens in your
system browser. If
url corresponds to a file in the
installed product documentation, then the page displays in the MATLAB Help browser instead of the web browser.
opt— Browser option
Browser option, specified as one of the following. Options can appear in any order.
Opens the page in a system browser window instead of the MATLAB web browser. On Microsoft® Windows® and Apple Macintosh platforms, the operating system determines the system web browser. On other systems, the default is the Mozilla® Firefox® browser, but you can change the default using MATLAB web preferences.
Opens the page in a new MATLAB web browser window. Does not apply when the page opens in your system browser.
Opens the page in a browser that does not display the address box. Only applies to new instances of the MATLAB web browser.
Opens the page in a browser that does not display a toolbar or address box. Only applies to new instances of the MATLAB web browser.
stat— Browser status
Browser status, returned as an integer with one of these values:
Found and started system browser.
Could not find system browser.
Found, but could not start system browser.
h— Handle to most recent MATLAB web browser
Handle to the most recent MATLAB web browser, returned as a scalar instance of the associated
Java® class. If the page opens in a system browser,
h is empty,
If you do not request the handle when you open the page, the handle might
not correspond to your most recent use of the
function. Other MATLAB functionality also uses the
such as links to external sites from the Help browser.
url— Current page address
Current page address in the most recent MATLAB web browser, returned as a character vector or string.
url has the same data type as the input argument
url. If the page opens in a system browser,
url is empty,
Online only supports the
web(url) syntax. Calling
web(url) in MATLAB
Online™ opens the page specified by
url in your web
browser instead of the MATLAB web browser.
To open external sites in the MATLAB browser instead of your system browser by default, go to the Home tab, and in the Environment section, click Preferences. Select MATLAB > Web and in the System Web browser section, clear Use system web browser when opening links to external sites (recommended). Using the system browser is recommended when opening external sites.
If you plan to deploy an application that calls the
using the MATLAB
Compiler™ product, then use the
If you are displaying Japanese streaming text in the MATLAB web
browser, specify a header that includes the
web(['text://<html><head><meta http-equiv="content-type" ' ... 'content="text/html;charset=utf-8"></head><body>TEXT</body></html>'])
Behavior changed in R2019b
web function now opens external sites using your system
browser by default. Previously, the
web function opened
external sites using the MATLAB browser. Using the system browser is recommended when opening external
To use the MATLAB browser as the default browser for external sites, go to the Home tab, and in the Environment section, click Preferences. Select MATLAB > Web and in the System Web browser section, clear the Use system web browser when opening links to external sites (recommended) option.