title: Insert figure/image to Excel from MATLAB
body: <p>I'm building my own Excel Add-in using MATLAB Library Compiler.
  I'm trying to build a function/add-in which takes two columns of data and plots it on a graph.
  I can not figure out how to insert the figure from the MATLAB function into Excel.</p>
  <p><strong>Example</strong></p>
  <hr />
  <p>We have a MATLAB function called plot2D, which looks like this:</p>
  <pre><code>function [fig] = plot2D(DataX,DataY)
      fig = figure;
      plot(DataX, DataY,'r--');
  end
  </code></pre>
  <p>We now use MATLAB Library Compiler and compile it into a <em>xla</em>-file and import it into Excel.
  What I want is whenever I use this add-in it should generate a graph inside the current Excel sheet, given two data entries.</p>
  <p><a href="https://i.stack.imgur.com/Ixgqp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ixgqp.png" alt="Plot2D function" /></a></p>
  <p>Now this doesn't work since Excel can't read the datatype <em>figure</em> of MATLAB.
  But how would I go about this? Any suggestions?
  Thank you.</p>