Path: news.mathworks.com!not-for-mail
From: "Ashish Uthama" <first.last@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: excel matlab connection and execution
Date: Wed, 29 Oct 2008 08:32:25 -0400
Organization: TMW
Lines: 90
Message-ID: <op.ujsc4bxqa5ziv5@uthamaa.dhcp.mathworks.com>
References: <ge7via$ogo$1@fred.mathworks.com>
 <op.ujq880pha5ziv5@uthamaa.dhcp.mathworks.com>
 <ge93hh$c1d$1@fred.mathworks.com>
NNTP-Posting-Host: uthamaa.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1225283546 3949 172.31.57.126 (29 Oct 2008 12:32:26 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 29 Oct 2008 12:32:26 +0000 (UTC)
User-Agent: Opera Mail/9.60 (Win32)
Xref: news.mathworks.com comp.soft-sys.matlab:497802


apologies
I forgot the '!'
try this in the MATLAB command window:
matlabprompt>!matlab -regserver

You can also look at (explains how to do this from the windows command  
prompt):
http://www.mathworks.com/support/solutions/data/1-S09OT.html?solution=1-S09OT



On Wed, 29 Oct 2008 03:32:01 -0400, Filip T?rnqvist  
<filto338@student.liu.se> wrote:

> We just tried this and matlab refuses to accept the command
> matlab -regserver in the main window. We only get a message saying  
> undefined function or variable.
>
> Best regards
> /Filip and Oskar
>
> "Ashish Uthama" <first.last@mathworks.com> wrote in message  
> <op.ujq880pha5ziv5@uthamaa.dhcp.mathworks.com>...
>> Excel uses the registry to obtain the path/version of MATLAB to use for
>> this command:
>> > Set MatLab = CreateObject("Matlab.Application")
>> Only one version of MATLAB may be registered using this per computer.
>>
>> To ensure that MATLAB is registered and is indeed in the registry for
>> Excel to find, do this:
>>
>> 1. Open the version of MATLAB you would like to use
>> 2. type this in thecommand window:
>>      matlab -regserver
>> 3. Type 'exit' in the new MATLAB command window that opens.
>> 4. Close the main MATLAB session
>> 5. Try your excel app..
>>
>>
>> On Tue, 28 Oct 2008 17:18:02 -0400, Filip T?rnqvist
>> <filto338@student.liu.se> wrote:
>>
>> > 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
>