Path: news.mathworks.com!not-for-mail
From: "Filip T?rnqvist" <filto338@student.liu.se>
Newsgroups: comp.soft-sys.matlab
Subject: Re: excel matlab connection and execution
Date: Wed, 29 Oct 2008 20:04:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 57
Message-ID: <geafji$282$1@fred.mathworks.com>
References: <ge7via$ogo$1@fred.mathworks.com> <ge9avl$8g2$1@fred.mathworks.com> <gea5bd$aeo$1@fred.mathworks.com>
Reply-To: "Filip T?rnqvist" <filto338@student.liu.se>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1225310642 2306 172.30.248.35 (29 Oct 2008 20:04:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 29 Oct 2008 20:04:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1575758
Xref: news.mathworks.com comp.soft-sys.matlab:497877


Hey
Thank you for the tip Ben. We'll have a look at thatprogram. Can we execute other m-files from excel with this interface? Since we have a GA-algorithm we'd like to run from excel we need this possibility.

"Ben Hinchliffe" <ben.hinchliffe@bluereference.com> wrote in message <gea5bd$aeo$1@fred.mathworks.com>...
> Hi Filip and Oskar,
> You may want to try using an add-in for Excel and Word called Inference for MATLAB.  Inference enables you to combine MATLAB commands, MATLAB software objects, data, and text within an Excel or Word document.  This document can then be executed to generate a results document (report). 
> By using Inference, you can avoid the hassle of visualbasic and working with the Office object model.
> You can download a free 120-day trial of Inference for MATLAB at www.InferenceForMATLAB.com
> Hope this helps!
> -Ben
> 
> "Filip T?rnqvist" <filto338@student.liu.se> wrote in message <ge9avl$8g2$1@fred.mathworks.com>...
> > Do you mean the windows commandwindow or the matlab one?
> > If we run the VB code we only get 65535 as the result. Eventhough we do send something else.
> > 
> > Best regards
> > /Filip and Oskar
> > 
> > "Filip T?rnqvist" <filto338@student.liu.se> wrote in message <ge7via$ogo$1@fred.mathworks.com>...
> > > Hello!
> > > 
> > > We're trying to connect and run matlab from excel using a subroutine(executed via a commandbutton in excel) with the following visualbasic code:
> > > 
> > > Sub Exc_to_Mat()
> > > 
> > > Dim MatLab As Object
> > > Dim result As String
> > > Dim MReal() As Double
> > > Dim MImag() As Double
> > >   
> > > Set MatLab = CreateObject("Matlab.Application")
> > > 
> > > Call MatLab.Execute("clear all")
> > > Call MatLab.Execute("cd C:\My_Docs\Kurser_T\ProduktModellering_TMKT57\Excel_Matlab")
> > > Call MatLab.Execute("test1([ " & ThisWorkbook.Worksheets("sheet1").Range("C5").Value _
> > > & " " & ThisWorkbook.Worksheets("sheet1").Range("C6").Value _
> > > & " " & ThisWorkbook.Worksheets("sheet1").Range("C7").Value & "])")
> > > Call MatLab.Execute("ans")
> > > 
> > > Call MatLab.GetFullMatrix("ans", "base", MReal, MImag)
> > > 
> > > ThisWorkbook.Worksheets("sheet1").Range("Stress").Value = MReal
> > > 
> > > End Sub
> > > 
> > > Running the m-file called test1 which looks like this:
> > > 
> > > function Stress= test1(x);
> > > Radius = x(1);
> > > Thickness = x(2);
> > > Pressure = x(3);
> > > Stress = Pressure*Radius/Thickness;
> > > 
> > > This connection will work and run on a computer using the 2006b licens but not a computer using the 2007a what might be the problem? Have we forgotten to add references in excel in order to be able to run these types o files? Or have the possibility to run these types of codes been removed from the 2007 version?
> > > 
> > > Best regards 
> > > /Filip and Oskar