MATLAB: How to launch a web browser or an .html file through MATLAB

alonebrowserhtmllaunchMATLABstandweb

I want to launch a web browser or an .html file through MATLAB.

Best Answer

You can launch a web browser or an .html file through MATLAB either by using the WEB command or the DOS command. Here are two ways to launch a web browser using MATLAB:
1. The WEB Command
This launches the URL or html file in the default browser for MATLAB - not Internet Explorer or Netscape, but the browser shipped with MATLAB. The WEB command launches the URL in this browser window. For more information, refer to the MATLAB documentation, using either
help web
or
doc web
at the MATLAB command prompt.
2. Using DOS commands through MATLAB.
The following example launches a new window every time a URL or an html file is called:
a.
dos('explorer http://www.yahoo.com');
dos('explorer test.html');
The following example uses the same explorer window to launch a URL or an html file:
b.
dos('start D:\Applications\Matlab_R12.1\help\search1.html');
dos('start http://www.yahoo.com');
The following example shows how to dynamically generate a URL from MATLAB variables and launch it in the browser:
c.
googleSubSite = {'shopping','wallet','finance'};
% launch 3 browser windows or tabs
for i = 1:3
dos(['start www.google.com/' googleSubSite{i}])
end
If you are planning to launch a web browser through stand-alone code generated using MATLAB, use the DOS command and not the WEB command. (The WEB command uses objects, which are not supported when compiling with the MATLAB compiler.)