Publish Technics, Script for better Publishing understanding under R14
Contents
PUBLISH_TECHNICS - Description
PUBLISH_TECHNICS is a M-Script to show and explain how the "Publish to
HTML" technics does works which are new in MATLAB R14.
Here will be shown different cases and Text formats as well as some
Tricks and Tips.
Publishing to HTML does work from the MATLAB Editor / Debugger IDE using
File -> Publish to HTML as well as command publish from MATLAB
Command Window.
AUTHOR : Frank Gonzalez-Morphy
$DATE : 23-Jul-2004 19:37:53 $ CREATION: 15-Jul-2004 16:38:10 $
$Revision : 1.19 $
DEVELOPED : 7.0.0.19920 (R14)
FILENAME : publish_technics.m
Chapter 1: - Text Outputs
Text Content
- Grayed Text on HTML Page using following commands:
disp(' These Text was created using >>disp('' text '') while')
disp(' publishing the M-File. The execution of the DISP command ')
disp(' generated the grayed Text')
These Text was created using >>disp(' text ') while
publishing the M-File. The execution of the DISP command
generated the grayed Text
Chapter 1.1: - Text Formatings
Text Formatings ...
These is normal Text looking in the Published HTML File - (1) blank space after the "%"-Symbol
These is Monospaced Text - (2) blank spaces after the "%"-Symbol
o Monospaced Text: |Monospaced Text|
o Preformatted Text:
Text - line
Text - line
o Bold Text: BOLD TEXT
Line 33 - start text ...
Bold Text throughout multiple lines ...
- beginning in Line 33 with an asterisk
- and end in Line 35 with an asterisk
last line - Line 35
o Bullet Listning: - Art 1 (*) [asterisk]
- BULLETED LIST - ITEM 1
- ITEM 2
- ITEM 3
- ITEM 4
- ITEM 5
- Sub Bulleting ? (Double **) => No, but free Bullet space
o Bullet Listning: - Art 2 (o) ['o' character]
o ITEM 1
o ITEM 2
o ITEM 3
o ITEM 4
Chapter 2: - Formating Text and getting none wrapped lines
These is an explanation text having multiple lines of text and it would be wrap as not formated text.
These large text line could be more then two lines, but it will automatically breaked and wrapped from the publish command. To have a dedicated new line you must have after text a blank line beginning with the "%"-Symbol. NOTE: If the beginning of the first Text character of a multiple line Text is 1 blank space then it's displayed as normal text
Format (wrapped). If the beginning of the Text is 2 blank spaces it will be displayed as Monospaced Text (un-wrapped).
Like these:
First Line (let formated text !)
Second Line
Third Line
- Interleaving a Line in between
To have a space in between to lines you must use the "%%" comment symbols after a blank line, like:
First Line
%%
Second LineYou must add a "%%" and then you get a new line for you Text.
... or must write so much text, that the line is larger as the limitation in the Editor / Debugger Preferences are set and
the Text will be wrapped.
Chapter 3: - Calculating operations and capturization of results
To capturize the Output directly after a command you must write on the next line after the command a "%%"-Symbol, then it
could be executed and if the result should be shown (none semicolon ending [;]), then it is displayed in grey color.
Magic square data of 4 ... does mean that horizontally as well vertically the sum is equal!
m = magic(4)
m =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
row_1_sum = sum(m(1,:))
row_1_sum =
34
row_2_sum = sum(m(2,:));
row_3_sum = sum(m(3,:));
row_4_sum = sum(m(4,:));
col_1_sum = sum(m(:,1));
col_2_sum = sum(m(:,2));
col_3_sum = sum(m(:,3));
col_4_sum = sum(m(:,4));
sum_diag = sum(diag(m))
sum_diag =
34
m(1,6) = row_1_sum; m(2,6) = row_2_sum; m(3,6) = row_3_sum;
m(4,6) = row_4_sum;
m(6,1) = col_1_sum; m(6,2) = col_2_sum; m(6,3) = col_3_sum;
m(6,4) = col_4_sum;
m(6,6) = sum_diag
m =
16 2 3 13 0 34
5 11 10 8 0 34
9 7 6 12 0 34
4 14 15 1 0 34
0 0 0 0 0 0
34 34 34 34 0 34
Chapter 4: - LaTex
LaTex Function listings :
LaTex Code: $$0 \leq x \leq 6\pi$$
Chapter 5: - Tricks with Links
Tricks using Links
... OR
http://www.mathworks.com HomePage
- Creating a Picture Link: Picture Name after "%%" in new line and between 2 beginning and ending arrow brackets
">" and 1 space after "%"-Symbol.
Chapter 6.1: - Screenshots of Figures and Plots
In folowing you will find some examples of screenshots of Messageboxes and Figures as well GUI's which are executed and take
an screenshot and paste them on the created HTML Page.
- Poping up Windows, like a Message Box just call it and it will be saved as screenshot in the HTML-Help:
msgbox('These is a MessageBox Screenshot!','Publishing ... ','help');
- Computation and execution of MATLAB Code with Figures and Plots.
Define the range for x. Calculate and plot y = sin(x).
x = 0:0.125:6*pi;
y = sin(x);
plot(x,y);
Put here additional Text into the Report between the Code, Screenshots and Text ...
Chapter 6.2: - Modify Plot Properties
title('Sine Wave', 'FontWeight', 'bold')
xlabel('x')
ylabel('sin(x)')
set(gca, 'Color', 'w')
set(gcf, 'MenuBar', 'none')
Chapter 7: - Publish Help
Help could be found under: >> doc publish
or
>> web(['jar:file:', docroot, '/techdoc/help.jar!/matlab_env/notebook.html'], '-helpbrowser')
Chapter 8: - MATLAB Commands
MATLAB Command: >> publish('M-File','html')
- i.e. these file was publish using >> p = publish('publish_technics','html');
To see the created file execute >> web(p)
- Options to avoid Display of Code in HTML Output use a structure :
>> publish_options.format = 'html';
>> publish_options.showCode = false;
>> p = publish('publish_technics', publish_options); >> web(p)
- Option to use another Style Sheet for HTML Output:
>> publish_options.stylesheet = 'myStyleSheet.xsl';
>> p = publish('publish_technics', publish_options); >> web(p)
- Use grabcode('filename.html') to extract the implemented M-Code
- Use GRABCODE to extract from an URL the implemented M-Code:
>> grabcode('http://www.mathworks.com/products/demos/matlab/census/census.html')Chapter 9: - Here used Files
- publish_technics.m ............. Content
- TMW_Logo_published.jpg ......... Header Picture
NOTES about PUBLISH
- "Publish to HTML" does only work for SCRIPTS !!!
- Additional "%" Symbols doesn't make break lines, instead use "%%" before new line ! Or you use 2 blank spaces after "%"-Symbol.
- If you want to modify the mainly look of the HTML generated Page then you must edit or copy and rename the file mxdom2simplehtml.xsl which is in the Directory ... $matlabroot$\toolbox\matlab\codetools\private\mxdom2simplehtml.xsl ... saved. If renamed point either through the Preferences of the MATLAB Editor or through the options when calling
the publish command to your modified and adapted StyleSheet (*.xsl).
>> edit('private/mxdom2simplehtml.xsl')
Signature
Created by Frank González-Morphy ...
disp(sprintf([' HTML Document created by Frank González-Morphy \n', ...
' Last Update: %s'], datestr(now)))
HTML Document created by Frank González-Morphy
Last Update: 25-Jul-2004 11:50:53
TellWhenPublishingFinished = msgbox('Finish Publishing. HTML created!','Publishing ... ','help');