I want to use Matlab to take in some data, run analysis on it, and then output the resulting analysis into an excel spreadsheet with some graphs. I know how to input data into Matlab and I know how to do the analysis and write the resulting data/matrices from Matlab onto Excel, but I am having trouble using Matlab to plot the data on Excel. I have come across this code that has been of huge help and can plot the data I want, but I have some additional questions. How can I modify this code to:
- How can I make plots on the sheets where the data is located (So how do I change the positon of where the chart is located)?
- How can I plot multiple series on one graph?
- Can anyone point me to some documentation that is relevant when using actxserver function on Excel?
- Also can someone tell me what the actxserver function and invoke function in Matlab do? I read the description but I have no idea what an OLE Automation server and Dynamic Link Library are so I would greatly appreciate if someone can help me understand.
Thank you!!!
Excel = actxserver('Excel.Application');
WB = Excel.Workbooks.Open('C:\Users\Alberto\Desktop\test.xlsx');
Chart = invoke(WB.Charts,'Add');
SheetObj = Excel.Worksheets.get('Item', 'Sheet1');
Chart.Name = 'TestChart';
Srs = Chart.SeriesCollection.Add(SheetObj.Range('B2:B16'));
Srs.XValues = SheetObj.Range('A2:A16');
Srs.Name = 'Test Series';
Chart.ChartType = 'xlLine';
Chart.ChartTitle.Text = 'Test Title';