Documentation

This is machine translation

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

라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

grabcode

Extract MATLAB code from file published to HTML

Syntax

grabcode('name.html')
grabcode('urlname')
code = grabcode('name.html')

Description

grabcode('name.html') copies MATLAB® code from the file name.html 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. The file name.html was created by publishing name.m, a MATLAB code file containing cells. The MATLAB code from name.m is included at the end of name.html as HTML comments.

grabcode('urlname') copies MATLAB code from the urlname location and pastes it into an untitled document in the Editor.

code = grabcode('name.html') gets MATLAB code from the file name.html and assigns it the variable code.

Examples

This example illustrates how to use grabcode to get MATLAB code from an existing HTML file:

% Copy sine_wave_f.html and the images it includes 
% from the MATLAB examples directory to your 
% current folder:

copyfile(fullfile(matlabroot,'help','techdoc','matlab_env',...
	'examples','sine_wave_f.html'), 'my_sine_wave.html')

copyfile(fullfile(matlabroot,'help','techdoc','matlab_env',...
	'examples','sine_wave_f_01.png'), 'sine_wave_f_01.png')

copyfile(fullfile(matlabroot,'help','techdoc','matlab_env',...
	'examples','sine_wave_f_02.png'), 'sine_wave_f_02.png')

% If you want to view the file, double-click my_sine_wave.html 
% in your current folder.

% Extract the MATLAB code from sine_wave_f.html:
code = grabcode('my_sine_wave.html')

MATLAB returns:

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') 

See Also

Introduced before R2006a

Was this topic helpful?