Unten finden Sie den Code, den das Mathworks Support Team (Link unten) zum Einfügen von MATLAB Figure in ein Excel-Blatt zur Verfügung stellt. Möglicherweise müssen Sie das Blatt auf die gewünschte aktualisieren.
% 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 der Antwort oben:
Eine Funktion img2xlsx
durch H K.Berg -, die eine oder mehrere Bild-Übertragungen (s) in eine neue oder bestehende xlsx-Datei) können downloaded von MATLAB Central sein
arbeiten Sie unter Linux oder Windows? – bushmills