Search code examples
matlabchartsexport-to-excel

Create new Excel document with charts in Matlab


Is it possible do automatically create an Excel chart in a new Excel file in Matlab?

I have a script calculating different things. At the end of the script, when all numbers are calculated, I want the script to plot several Excel charts (XY scatter with smooth lines) using the calculated numbers.

The charts should be ready to use, with legend below the chart, x and y axis description, and (if possible) changed font type.

(I know that I can plot this in Matlab, but I prefer the Excel look)

If anyone has examples of such a code, or a reference to where this is explained, I'd be very happy!


Solution

  • I've done this using the COM activeX server. Check out this link:

    http://www.codeproject.com/Tips/536603/Insert-a-Chart-in-Excel-through-Matlab

    I used to do everything from Matlab, but after a while I started writing VBA scripts within the worksheet and then call them from Matlab after exporting data. You just need some VBA syntax and you should be good to go.