| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB Builder NE |
| Contents | Index |
| Learn more about MATLAB Builder NE |
| On this page… |
|---|
Preparing a MATLAB Figure for Export |

Create a figure window. For example:
h = figure;
Add graphics to the figure. For example:
surf(peaks);
Optionally, you can change the figure numerous ways. For example:
set(h, 'Visible', 'off');
set(h, 'Color', [.8,.9,1]);
width=500; height=500; rotation=30; elevation=30; set(h, 'Position', [0, 0, width, height]); view([rotation, elevation]);
Export the contents of the figure in one of two ways:
To export as a WebFigure:
returnFigure = webfigure(h);
To export image data, for example:
imgform = 'png';
returnByteArray = figToImStream(`figHandle', h, ...
`imageFormat', imgForm, ...
`outputType', `uint8');
To close the figure window:
close(h);
function returnFigure = getWebFigure()
h = figure;
set(h, 'Visible', 'off');
surf(peaks);
set(h, 'Color', [.8,.9,1]);
returnFigure = webfigure(h);
close(h);
function returnByteArray = getImageDataOrientation(height, width,
elevation, rotation, imageFormat )
h = figure;
set(h, 'Visible', 'off');
surf(peaks);
set(h, 'Color', [.8,.9,1]);
set(h, 'Position', [0, 0, width, height]);
view([rotation, elevation]);
returnByteArray = figToImStream(`figHandle', h, ...
`imageFormat', imageFormat, ...
`outputType', `uint8');
close(h);
![]() | Working with MATLAB Figures and Images | Working with MATLAB Figure and Image Data | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |