Excel Chart with 2 X-axis through matlab
Show older comments
I want to make a program that will make an Excel chart with 2 X-axis and Y-axis. how can I add the second X-axis?
my second X-axis is 'Sheet2', C3: C ...
here is my code
Excel = actxserver('excel.application');
% Get Workbook object
WB = Excel.Workbooks.Open(outname);
% Get neu Worksheets object
WS = WB.Worksheets;
WS.Add([], WS.Item(WS.Count));
Sheet=WB.Worksheets.Item('Sheet2');
Charts = WB.Charts;
Chart = invoke(Charts,'Add');
invoke(Excel.ActiveChart.SeriesCollection,'NewSeries');
Excel.ActiveChart.SeriesCollection(1).Name = 'Temberatur';
Excel.ActiveChart.SeriesCollection(1).XValues = Sheet.Range(strcat('B3:B',num2str(C)));
Excel.ActiveChart.SeriesCollection(1).Values = Sheet.Range(strcat('A3:A',num2str(C)));
% Setting the Chart Sheet Title & Chart Title.
Excel.ActiveChart.HasTitle = 1;
Excel.ActiveChart.ChartTitle.Characters.Text = 'Temperature';
Excel.ActiveChart.Name = 'Temperatur';
% Setting the (X-Axis) and (Y-Axis) titles.
ChartAxes = invoke(Chart,'Axes',1);
set(ChartAxes,'HasTitle',1);
set(ChartAxes.AxisTitle,'Caption','Temperature /°C');
ChartAxes = invoke(Chart,'Axes',2);
set(ChartAxes,'HasTitle',2);
set(ChartAxes.AxisTitle,'Caption','Depth /m');
Excel.ActiveChart.ChartType = 65;
% Setting the (Y-Axis) Scale
Excel.ActiveChart.Axes(2).Select;
Excel.ActiveChart.Axes(2).MinimumScale = 0;
Excel.ActiveChart.Axes(2).MaximumScale = max(handles.tiefe(:,C));
Excel.ActiveChart.Axes(2).ReversePlotOrder = true;
Accepted Answer
More Answers (0)
Categories
Find more on Use COM Objects in MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!