Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

grabcode

Extract MATLAB code from file published to HTML

Syntax

grabcode filename
grabcode url
code = grabcode(filename)

Description

grabcode filename copies the MATLAB® code from the HTML file filename and pastes it into an untitled document in the Editor. Use grabcode to get MATLAB code from published files when the source code is not readily available. filename is the HTML file created by publishing a MATLAB code file (*.m) or exporting a live script (*.mlx) to HTML. In both cases, the MATLAB code from the file appears as HTML comments at the end of filename.

grabcode url copies MATLAB code from the page or file specified by url and pastes it into an untitled document in the Editor.

example

code = grabcode(filename) returns the MATLAB code from filename to a character array.

Examples

collapse all

Use grabcode to get MATLAB® code from an existing HTML file.

Extract the MATLAB code from my_sine_wave.html into the variable code. To view the contents of the file, double-click my_sine_wave.html in your current folder.

code = grabcode('my_sine_wave.html')
code = 
    '%% Plot Sine Wave
     % Calculate and plot a sine wave.
     %% Calculate and Plot Sine Wave
     % Calculate and plot |y = sin(x)|.
     function sine_wave_f(x)
     y = sin(x);
     plot(x,y)
     %% Modify Plot Properties
     title('Sine Wave', 'FontWeight','bold')
     xlabel('x')
     ylabel('sin(x)')
     set(gca, 'Color', 'w')
     set(gcf, 'MenuBar', 'none') '

Input Arguments

collapse all

Name of the HTML file, specified as a character vector.

Example: name.html

Web page address or location of HTML file, specified as a character vector.

Example: http://www.mathworks.com/matlabcode.html

Introduced before R2006a

Was this topic helpful?