| MATLAB Function Reference | ![]() |
MATLAB® code from M-files published to HTML
grabcode('name.html')
grabcode('urlname')
codeString = grabcode('name.html')
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 demos or other published M-files when the M-file source code is not readily available. The file name.html was created by publishing name.m, an M-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.
codeString = grabcode('name.html') get MATLAB code from the file name.html and assigns it the variable codeString.
Run
sineWaveString = grabcode('d:/mymfiles/sine_wave_.html')and MATLAB displays
sineWaveString = %% Simple Sine Wave Plot %% Part One: Calculate Sine Wave % Define the range |x|. % Calculate the sine |y| over that range. x = 0:.01:6*pi; y = sin(x); %% Part Two: Plot Sine Wave % Graph the result. plot(x,y)
![]() | gplot | gradient | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |