Example of Basic Script file 7

Lisa Oberbroeckling, Spring 2012

Contents

close all
clc

Important! For brevity, I have not shown in the published version how to achive the formatting that is shown in this file. Thus to get complete information on formatting text as shown in this file, you should view the m-file.

Basic text formatting

In order to create a new line or new paragraph of text, have a blank comment line in between the lines,

Here is a paragraph that just goes on, and on, and on, and on, and on, and on, and on, and on, and on, and on, and on, and on. Still going on, and on, and on, and on, and on, and on.

Then we have a new line/paragraph.

Text can be bold, italic, and/or monospaced. One can also combine these formats like:

BOLD, ITALIC TEXT

ITALIC, MONOSPACED TEXT

Unordered (Bulleted) List

Keep in mind that you must have a cell break before the list, with or without a section title. You also must have a blank comment line to end the list. Here's another example.

Ordered (Numbered) List

  1. first item
  2. second item blah blah

As in the bulleted list, one must have a cell break, with or without a section title. Second example without section title:

  1. blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
  2. yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda

Inserting links

You can have the links display the URL or display other text.

Here's an example of using the URL as the text of the link: http://www.mathworks.com

Here's an example of having other text as the link: MathWorks

LINKING THE M-FILE It may be nice (required!) to link the M-File that was published to create the webpage. The easiest way to do it is like this M-File for this page.

IMPORTANT: the text within the "<" and ">" must be on one line within the file. The editor might automatically wrap the text if the URL and/or the text for the link is long. If this is the case, go back and make it one line.

Inserting an Image

The image must be on its own line - no text can appear before or after it for the image to be shown correctly on the page. Also note that the the line is assuming the file for the image is located in the "html" folder into which the HTML file the M-file produced is located.

Preformatted Text and Displaying Code

IMPORTANT: notice that the code below doesn't appear any different than plain comments. In order for it to be preformatted, you MUST use the menu item "Preformatted Text" or "Code" on the "Publish" tab within Matlab to insert the lines and change it. When you select "Preformatted Text" here is what the menu item inserts:

PREFORMATTED
TEXT

Then you change the works "PREFORMATTED" AND "TEXT" and add lines if necessary:

preformatted text
 displayed
exactly
as it appears   in     the    editor
(commonly used to display lines of code but is better to use Code)
------------------------------------------------------
function y = myexample(x)
% MYEXAMPLE(X) is a function for example purposed only
%
y = x.^2;
------------------------------------------------------

Similarly, when you select "Code" it adds the lines

for x = 1:10
    disp(x)
end

and you change the selected code to your own:

function y = myexample(x)
% MYEXAMPLE(X) is a function for example purposed only
%
y = x.^2;

Notice how the coloring is better using Code rather than Preformatted Text.

Inserting HTML Code

onetwo

Inserting LaTeX Equations

One can insert basic LaTeX commands and equations between 2 dollar signs. One can have LaTeX code with the paragraph like $$ e^{\pi i} + 1 = 0 $$ or on a separate line.

$$ y_1 = \frac{d}{dx}\int_0^{\pi x} e^{\theta^2} d\theta $$

Notice that the "not equals" symbol now works! (it did not in previous versions) $$ 0 \ne 1 $$

BETTER MATH TEXT: USE MATHJAX!

(New! Added 2018) By inserting the following code at the top of your m-file, you can use Mathjax to display mathematics using LaTeX code that works in all browsers. It shows up better than MATLAB's publishing, which creates images of the equations, slowing the page down. More importanly, MATHJAX is more accessible!

<html>
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML'></script>
</html>

For inline math, instead of

$$ e^{\pi i} + 1 = 0 $$

use

\( e^{\pi i} + 1 = 0 \)

And for displayed equations, use

\[ y_1 = \frac{d}{dx}\int_0^{\pi x} e^{\theta^2} d\theta \]

Here are the same mathematics as in the previous section now displayed with MathJax: \( e^{\pi i} + 1 = 0 \)

\[ y_1 = \frac{d}{dx}\int_0^{\pi x} e^{\theta^2} d\theta \]

Some more examples: inline: \( \lim_{n \to \infty} \sum_{k=1}^n f(x_k^*)\Delta x = \int_a^b f(t)\ dt = F(t) + C \) and displayed equations: \[ \lim_{n \to \infty} \sum_{k=1}^n f(x_k^*)\Delta x = \int_a^b f(t)\ dt = F(t) + C \] \[ \sqrt{a^2 + b^2} \ne a + b \]

M-file that created this page

publishMFile7.m