Thread Subject: Matlab builder for excel - Optimization

Subject: Matlab builder for excel - Optimization

From: Subrat Swain

Date: 17 Oct, 2008 20:42:02

Message: 1 of 3

Hi all,
I am facing a problem while compiling my .M files in Matlab builder for excel. I am having M files in Matlab which I want to export it to Excel VBA and create a VBA code which will help me in doing computation in excel.This is a simple Optimization problem with objective function as = X^2-2 and I have to maximize it. My constraints are X<=5.
 Right now my M files are as follows;
  Objective function file:
     function f = objfun(x)
     f = (x(1)*x(1)-2);
  Constraint function file:
     function [c, ceq] = confun(x)
     c = [x(1)-5];
     ceq = [];
  Final script file (final.m)
     x0 = [-1,1];
     options = optimset('LargeScale','off');
     [x, fval] = ...
     fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options)

This is getting executed properly in MATLAB but when using MATLAB Builder for creating COM files (.dll) I am getting an
error mentioned below after providing above 3 .M files under the 'Add files' tab of the MATLAB Builder.

       'Error executing mcc, return status = 1'
The error report says that the file 'final.m' is a script file and it cannot be compiled with the present compiler.
But when I tried to execute it in the system having Microsoft Visual C/C++ version 6.5 compiler still I am facing the same error.
    
   I will be highly obliged if any one can please help me out of this problem. Expecting a quick reply from your side.

Thanks and Regards,
Subrat Kumar Swain.

Subject: Matlab builder for excel - Optimization

From: Ashish Uthama

Date: 17 Oct, 2008 20:48:59

Message: 2 of 3

How much more descriptive can the error message get?

> The error report says that the file 'final.m' is a script file and it
> cannot be compiled with the present compiler.

The version of MATLAB you are using will not compile script files. You
would have to convert all script files to function (just add a function
final to the top to make it a function with no input/output args).

If your aim is to use the functionality of the following lines:
> options = optimset('LargeScale','off');
> [x, fval] = ...
> fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options)
where x0 is obtained from the Excel sheet. Convert this script to a
function which has x0 as its input. Compile and deploy it as an Excel add
in (follow the example in the doc) and then you can use a vector from the
Excel sheet as the input x0.

Please find more details online at:
     http://www.mathworks.com/access/helpdesk/help/toolbox/matlabxl/ug/f2-7373.html
Or please paste this in the MATLAB command window:
     web([docroot,'/toolbox/matlabxl/ug/f2-7373.html'])



On Fri, 17 Oct 2008 16:42:02 -0400, Subrat Swain
<swain.subrat01@gmail.com> wrote:

> Hi all,
> I am facing a problem while compiling my .M files in Matlab builder for
> excel. I am having M files in Matlab which I want to export it to Excel
> VBA and create a VBA code which will help me in doing computation in
> excel.This is a simple Optimization problem with objective function as =
> X^2-2 and I have to maximize it. My constraints are X<=5.
> Right now my M files are as follows;
> Objective function file:
> function f = objfun(x)
> f = (x(1)*x(1)-2);
> Constraint function file:
> function [c, ceq] = confun(x)
> c = [x(1)-5];
> ceq = [];
> Final script file (final.m)
> x0 = [-1,1];
> options = optimset('LargeScale','off');
> [x, fval] = ...
> fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options)
>
> This is getting executed properly in MATLAB but when using MATLAB
> Builder for creating COM files (.dll) I am getting an
> error mentioned below after providing above 3 .M files under the 'Add
> files' tab of the MATLAB Builder.
>
> 'Error executing mcc, return status = 1'
> The error report says that the file 'final.m' is a script file and it
> cannot be compiled with the present compiler.
> But when I tried to execute it in the system having Microsoft Visual
> C/C++ version 6.5 compiler still I am facing the same error.
> I will be highly obliged if any one can please help me out of this
> problem. Expecting a quick reply from your side.
>
> Thanks and Regards,
> Subrat Kumar Swain.
>
>

Subject: Matlab builder for excel - Optimization

From: Ben Hinchliffe

Date: 20 Oct, 2008 20:46:02

Message: 3 of 3

Hi Subrat,
I'm not sure why you're getting the error, but you may be able to avoid this problem by using Inference for MATLAB to execute MATLAB files/objects/commands directly in MS Excel and Word.
You don't have to know the Office object model (VBA)- Inference for MATLAB works as an add-in for Office, allowing users to combine MATLAB objects, MATLAB script/commands, data, and text annotations(commentary) in Excel and Word documents. These documents can be executed to produce "results documents" that contain textual, numerical, and graphical output of MATLAB commands.
A free trial is available at www.InferenceForMATLAB.com. Hope this helps!
Best,
-Ben

"Subrat Swain" <swain.subrat01@gmail.com> wrote in message <gdataq$ol6$1@fred.mathworks.com>...
> Hi all,
> I am facing a problem while compiling my .M files in Matlab builder for excel. I am having M files in Matlab which I want to export it to Excel VBA and create a VBA code which will help me in doing computation in excel.This is a simple Optimization problem with objective function as = X^2-2 and I have to maximize it. My constraints are X<=5.
> Right now my M files are as follows;
> Objective function file:
> function f = objfun(x)
> f = (x(1)*x(1)-2);
> Constraint function file:
> function [c, ceq] = confun(x)
> c = [x(1)-5];
> ceq = [];
> Final script file (final.m)
> x0 = [-1,1];
> options = optimset('LargeScale','off');
> [x, fval] = ...
> fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options)
>
> This is getting executed properly in MATLAB but when using MATLAB Builder for creating COM files (.dll) I am getting an
> error mentioned below after providing above 3 .M files under the 'Add files' tab of the MATLAB Builder.
>
> 'Error executing mcc, return status = 1'
> The error report says that the file 'final.m' is a script file and it cannot be compiled with the present compiler.
> But when I tried to execute it in the system having Microsoft Visual C/C++ version 6.5 compiler still I am facing the same error.
>
> I will be highly obliged if any one can please help me out of this problem. Expecting a quick reply from your side.
>
> Thanks and Regards,
> Subrat Kumar Swain.
>

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
excel Ben Hinchliffe 20 Oct, 2008 16:50:08
word Ben Hinchliffe 20 Oct, 2008 16:50:08
microsoft word Ben Hinchliffe 20 Oct, 2008 16:50:08
matlab script Ben Hinchliffe 20 Oct, 2008 16:50:08
matlab files Ben Hinchliffe 20 Oct, 2008 16:50:08
directly in excel Ben Hinchliffe 20 Oct, 2008 16:50:08
directly in word Ben Hinchliffe 20 Oct, 2008 16:50:08
vba Ben Hinchliffe 20 Oct, 2008 16:50:08
microsoft excel Ben Hinchliffe 20 Oct, 2008 16:50:08
matlab builder ... Ben Hinchliffe 20 Oct, 2008 16:50:08
ms excel Ben Hinchliffe 20 Oct, 2008 16:50:08
ms word Ben Hinchliffe 20 Oct, 2008 16:50:08
office object m... Ben Hinchliffe 20 Oct, 2008 16:50:08
matlab commands Ben Hinchliffe 20 Oct, 2008 16:50:07
matlab objects Ben Hinchliffe 20 Oct, 2008 16:50:07
execute Ben Hinchliffe 20 Oct, 2008 16:50:07
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com