How do you set the dimensions of an excel plot using activex from MATLAB?

Illustration
ava.smith01 - 2020-09-01T10:42:52+00:00
Question: How do you set the dimensions of an excel plot using activex from MATLAB?

I have constructed a xyscatter plot in excel using activex from matlab code but cant figure out how to dimension it. Here is the code that I have: Workbooks = Excel.Workbooks; Workbook = Workbooks.Add; Sheets = Excel.ActiveWorkBook.Sheets; sheet1 = get(Sheets, 'Item', 1); Activesheet = Excel.Activesheet; Range = 'A1:B10'; Data(:,1) = 1:10'; Data(:,2) = Data(:,1).^2; ActivesheetRange = get(Activesheet,'Range',Range); set(ActivesheetRange, 'Value', Data); Chart = invoke(Workbook.Charts,'Add'); Excel.ActiveChart.ChartType = 'xlXYScatterLinesNoMarkers'; invoke(Chart, 'SetSourceData', ActivesheetRange); Chart.Location('xlLocationAsObject', 'Sheet1');

Expert Answer

Profile picture of Prashant Kumar Prashant Kumar answered . 2025-11-20

I found what works:

 

 Excel.ActiveChart.Parent.Top = 50;
 Excel.ActiveChart.Parent.Left = 500;
 Excel.ActiveChart.Parent.Width = 600;
 Excel.ActiveChart.Parent.Height = 300;


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!