私の仕事は「Excelで円グラフを作成し、それをmatlabで表示する」ことです。
私が思うに、私には2つの問題があります:
1) このチャートは正しくチャートを作成していますか? (A1-A6 は名前、B1-B6 - 番号)。
わかりました、この機能は動作します。
Function CreateChart() As Excel.Chart
Dim title As String
title = "One"
Dim Book As Workbook
Set Book = ThisWorkbook
Dim new_sheet As Excel.Worksheet
Set new_sheet = Book.Sheets(1)
Dim new_chart As Excel.Chart
Set new_chart = Charts.Add()
ActiveChart.ChartType = xlPie
ActiveChart.SetSourceData Source:=new_sheet.Range("A1:B6"), _
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAutomatic, Name:=title
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = title
End With
Set CreateChart = new_chart
End Function
2) このプロシージャと対話する方法(将来的には - function、 Chart を返す)
matlab を使用して、この円グラフを matlab で描画しますか?
function chart = CreateChart( DataMatrix )
pie = actxserver('Excel.Chart');
all_pies = actxserver('Excel.Charts');
pietype = actxserver('Excel.XlChartType');
pie = all_pies.Add();
pie.ChartType = pietype.xlPie;
% here is a trouble to put data from matrix
pie.SetSourceData Source DataMatrix %hm.. strange
end
このコードは機能しません。(文字列を書き換える方法がわからない
ActiveChart.SetSourceData Source:=new_sheet.Range("A1:B6"), PloBy = xlColumns
)
PS: Excel ファイルからスクリプトを読み込んで Chart を返す方が良いと思います。
しかし、matlab でこのチャートを操作するにはどうすればよいでしょうか? (そしてそれを描く)