a- 1 | a-2 | a-3 | |||
aaa | 1 | 6 | 15 | ||
bbb | 2 | 7 | 14 | ||
ccc | 3 | 8 | 13 | ||
ddd | 4 | 9 | 12 | ||
eee | 5 | 10 | 11 |
You can save the graph created with this interface in an Excel file. This example uses a separate Excel Automation server process for this purpose. The callback for the Save Graph push button creates the image and adds it to an Excel file:
Both the axes and legend are copied to an invisible figure configured to print the graph as you see it on the screen (figure PaperPositionMode
property is set to auto
).
The print
command creates the PNG image.
Use the Shapes
interface to insert the image in the Excel workbook.
The server and interfaces are instanced during the initialization phase:
exl2 = actxserver('excel.application'); exlWkbk2 = exl2.Workbooks; wb = invoke(exlWkbk2,'Add'); graphSheet = invoke(wb.Sheets,'Add'); Shapes = graphSheet.Shapes;
Use this code to implement the Save Graph button callback:
function saveButtonCallback(src,evt) tempfig = figure('Visible','off','PaperPositionMode','auto'); tempfigfile = [tempname '.png']; ah = findobj(f,'type','axes'); copyobj(ah,tempfig) % Copy both graph axes and legend axes print(tempfig,'-dpng',tempfigfile); Shapes.AddPicture(tempfigfile,0,1,50,18,300,235); exl2.visible = 1; end
The other approach is to use the ActiveX interface to send VBA plotting commands to Excel. See an example
https://www.matlabsolutions.com/resources/plots-in-excel-sheets-using-matlab.php
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.