0

What is the right procedure to execute any excel function either built in or user-defined from Matlab?

AbbyJ
  • 75
  • 3
  • 9

3 Answers3

1

I think the command you are looking for is actxcontrol. A link to the doc is here.

http://www.mathworks.com/help/matlab/ref/actxcontrol.html

Here's a small general example from the MathWorks Support page:

http://www.mathworks.com/support/solutions/en/data/1-17PWC/index.html

kitchenette
  • 1,625
  • 11
  • 12
1

I know this thread is old - but it still pops up in google.

Calling an excel formula from MATLAB can be done directly by using an actxserver using a few lines of code. In this example I'll call the function STEYX as that has no direct equivalent in MATLAB afaik. 'x' and 'y' are MATLAB variables (in this case they must be vectors of identical size)

xlsobj = actxserver('Excel.Application'); syx = xlsobj.WorksheetFunction.StEyx(y,x);

And that's it...and similar syntax goes for all other Excel functions.

The error parsing from Excel is dreadful - make sure you know your inputs and know your Excel function.

JungleJim
  • 11
  • 1
0

Or you could use the system command and a .vbs script...

system('Your_excel_macro_launch_command_here')

Ways to do this are discussed here:

Way to run Excel macros from command line or batch file?

Community
  • 1
  • 1
Lee
  • 29,398
  • 28
  • 117
  • 170