Using 'publish' and 'fprintf' in 2011b and later
17 views (last 30 days)
Show older comments
I have some code written under Matlab 2009a which doesn't work under 2011b or later. This is true in both Win7 and Unix.
Essentially, using 'fprintf' with html-markers does not get interpreted when publishing code. Using 'disp' on the other hand works, but is obviously limited.
Here is a sample function:
function [] = codeToGenerateOutput()
%%Section 1
fprintf('<html><h3>This is some text</h3></html>')
fprintf('<html><a href = "http://www.mathworks.com">MathWorks Web Site</a></html>')
%%Section 2
disp('<html><h3>This is some text</h3></html>')
disp('<html><a href = "http://www.mathworks.com">MathWorks Web Site</a></html>')
Under 2009, this produces the following output when published:

Under 2011b (or 2014b), this produces the following output when published:

When viewing the source of the html, it turns out that Matlab 2011b inserts some pre class=”codeoutput” marker like this:
</h2><pre class="codeoutput"><html><h3>This is some text</h3></html><html><a href = "http://www.mathworks.com">MathWorks Web Site</a></html></pre><h2>Section 2<a name="4"></a></h2><h3>This is some text</h3></html>
<html><a href = "http://www.mathworks.com">MathWorks Web Site</a><p class="footer"><br>
Why does Matlab 2011b handle fprintf in this weird way?
Help is greatly appreciated!!
0 Comments
Answers (0)
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!