以下は、MATLAB FigureをExcelシートに挿入するためのMathworks Support Team(以下のリンク)が提供するコードです。シートを目的のものに更新する必要があるかもしれません。上記応答に
% Create sample image from figure
img = 'figure1.png';
plot(1:10);
print('-dpng', img);
% Get handle to Excel COM Server
Excel = actxserver('Excel.Application');
% Set it to visible
set(Excel,'Visible',1);
% Add a Workbook
Workbooks = Excel.Workbooks;
Workbook = invoke(Workbooks, 'Add');
% Get a handle to Sheets and select Sheet 1
Sheets = Excel.ActiveWorkBook.Sheets;
Sheet1 = get(Sheets, 'Item', 1);
Sheet1.Activate;
% Alternative 1 BEGIN.
% Get a handle to Shapes for Sheet 1
Shapes = Sheet1.Shapes;
% Add image
Shapes.AddPicture([pwd '\' img] ,0,1,400,18,300,235);
% Alternative 1 END.
% Alternative 2 BEGIN.
% Add image
Sheet1.invoke('Pictures').Insert([pwd '\' img]);
% Alternative 2 END.
% Save the workbook and Close Excel
invoke(Workbook, 'SaveAs', [pwd '\myfile.xls']);
invoke(Excel, 'Quit');
% In the above code (Alternative 1), Excel's Shapes.AddPicture Method is used to insert a figure in the Excel Sheet - Mathworks.
Link:H K.Bergによって
機能img2xlsx
- 新規または既存のXLSXファイル1つまたは複数の画像(複数可)を転送する)MATLAB Centralからdownloadedすることができます
LinuxまたはWindowsで作業していますか? – bushmills