从Matlab绘制excel条形图

时间:2013-08-10 19:26:57

标签: excel matlab

如何从Matlab绘制excel条形图?

我可以绘制折线图。

e = actxserver('excel.application');
eWs = e.Workbooks;
eW = eWs.Add;
eS = eW.ActiveSheet;
e.Visible = 1;

x=(0:2:100)';y=sin(x);
eS.Range('A1:B50').Value = [x y];

eCO = eS.ChartObjects.Add(100, 30, 400, 250);
eC = eCO.Chart;
eC.SeriesCollection.NewSeries;

eC.SeriesCollection(1).Value = eS.Range('B1:B50');
eC.SeriesCollection(1).XValue = eS.Range('A1:A50');
eCO.Chart.ChartType = 1;
eCO.Chart.ChartType = 65;

eCO.Chart.HasTitle = true;
eCO.Chart.ChartTitle.Text = 'This is the title text'; % view it again

eW.Close;e.Quit;delete(e);

1 个答案:

答案 0 :(得分:0)

好的,我发布之后就知道了。
我们可以通过改变

来实现这一目标

eCO.Chart.ChartType = 65;eCO.Chart.ChartType = 57;

e = actxserver('excel.application');
eWs = e.Workbooks;
eW = eWs.Add;
eS = eW.ActiveSheet;
e.Visible = 1;

x=(0:2:100)';y=sin(x);
eS.Range('A1:B50').Value = [x y];

eCO = eS.ChartObjects.Add(100, 30, 400, 250);
eC = eCO.Chart;
eC.SeriesCollection.NewSeries;

eC.SeriesCollection(1).Value = eS.Range('B1:B50');
eC.SeriesCollection(1).XValue = eS.Range('A1:A50');
eCO.Chart.ChartType = 1;
eCO.Chart.ChartType = 57;

eCO.Chart.HasTitle = true;
eCO.Chart.ChartTitle.Text = 'This is the title text'; % view it again

eW.Close;e.Quit;delete(e);

有关其他图表的进一步参考,请查看此http://it.toolbox.com/wiki/index.php/EXCEL_Chart_Type_Enumeration