MATLAB: display markup (HTML or other format)

I would like to display a table from a script in MATLAB . I can easily generate <td>other HTML elements, but as far as I know, I can only write them to a file.

Is there a way to display HTML (or some other markup) from MATLAB? Or am I stuck writing to a file and opening a browser?

+3
source share
4 answers

Use the Java Swing component inside the MATLAB drawing, namely JEditorPaneusing javacomponent()MATLAB javacomponent(). JEditorPane supports a good subset of HTML.

alt text

Here is a sample code:

mytext  = '<html><body><table border="1"><tr><th>Month</th><th>Savings</th></tr><tr><td>January</td><td>$100</td></tr></table></body></html>';

hfig    = figure();
je      = javax.swing.JEditorPane( 'text/html', mytext );
jp      = javax.swing.JScrollPane( je );

[hcomponent, hcontainer] = javacomponent( jp, [], hfig );
set( hcontainer, 'units', 'normalized', 'position', [0,0,1,1] );

%# Turn anti-aliasing on ( R2006a, java 5.0 )
java.lang.System.setProperty( 'awt.useSystemAAFontSettings', 'on' );
je.putClientProperty( javax.swing.JEditorPane.HONOR_DISPLAY_PROPERTIES, true );
je.putClientProperty( com.sun.java.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY, true );

je.setFont( java.awt.Font( 'Arial', java.awt.Font.PLAIN, 13 ) );

EDIT: see a discussion of this solution here ,

+4

UITABLE.

: ( ) , , , :

hFigure = figure('Position',[100 100 300 220]);
hTable = uitable(hFigure,'Data',rand(10,3),...
                 'ColumnName',{'X' 'Y' 'Z'},...
                 'Position',[20 20 260 180]);

alt text

+4

In the end, I did what I didn’t really want, namely to write HTML to a file. I need to open it in a browser and update every time I run my script, but this is not so bad for what I need in the short term.

0
source

Source: https://habr.com/ru/post/1725657/


All Articles