'===============================================
' Example1 Macro
' Macro recorded 02/21/95 by The MathWorks, Inc.
'===============================================
' Declare a Matlab variable here so it stays open
' when Sub Example1 goes out of scope
Dim MatLab As Object
Sub Example1()
'Create the Matlab Object
Set MatLab = CreateObject("Matlab.Application")
'Execute MATLAB commands
Result = MatLab.Execute("h=peaks(10);colormap(pink);mesh(h);drawnow")
'Get some matrix from MATLAB
Dim MReal(9, 9) As Double
Dim MImag() As Double
Dim RealValue As Double
Dim i, j As Integer
'Result = MatLab.Execute("a = [1 2 3 4; 5 6 7 8;]")
Call MatLab.GetFullMatrix("h", "base", MReal, MImag)
'Make sheet1 active. This selects the target sheet.
'Commenting out this line means that the sheet
'operated on is the current sheet.
Sheets("sheet1").Select
'Put in a string
Range("B10:B10").Value = "The content of variable h"
'Fill Excel sheet cells with data from MATLAB
Range("B11:K20").Value = MReal
Best Answer