Thread Subject: .m code to .exe | sim func. not working

Subject: .m code to .exe | sim func. not working

From: Blueblood Kingroyale

Date: 11 Mar, 2008 12:10:17

Message: 1 of 12

Hi I'm doing a Voice Rec project using neural networks.
Which is where the 'sim' function comes in (Neural Network
Toolbox).
When I convert the .m files to .exe, everything else except
the 'sim' function is working.
Any idea what I can do differently?

Subject: .m code to .exe | sim func. not working

From: Ashish Uthama

Date: 11 Mar, 2008 20:17:23

Message: 2 of 12

is it this
http://www.mathworks.com/support/solutions/data/1-15YVJB.html

or

http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/index.html?/access/helpdesk/help/toolbox/compiler/bqrvu87-6.html&http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/bq6ae_n-1.html

either way, you cannot compile SIM (the NN one).

If the link is mangled, go to the mathworks site, search for:
compiler Unsupported Functions sim

look for a link on 'Unsupported Functions'


On Tue, 11 Mar 2008 08:10:17 -0400, Blueblood Kingroyale
<edproject.cec@gmail.com> wrote:

> Hi I'm doing a Voice Rec project using neural networks.
> Which is where the 'sim' function comes in (Neural Network
> Toolbox).
> When I convert the .m files to .exe, everything else except
> the 'sim' function is working.
> Any idea what I can do differently?

Subject: how to write pragmas for unsupported function?

From: Blueblood Kingroyale

Date: 12 Mar, 2008 08:42:01

Message: 3 of 12

Hey thanks Ashish,
the link(http://www.mathworks.com/support/solutions/data/1-
15YVJB.html) you sent did help me to identify the problem
in a better way but I'm yet to find a solution.

'sim' function in the Neural Network toolbox is in the
list of unsupported functions (that can't be converted to
stand alone by mcc) somebody please explain how
can 'pragma'; that is %#function; be used to solve this
problem.

Subject: how to write pragmas for unsupported function?

From: Ashish Uthama

Date: 12 Mar, 2008 13:20:30

Message: 4 of 12


Its not a 'problem', I guess its a design(ed) issue :)

AFAIK, you cannot compile a NN which is expected to be trained outside
MATLAB, though you
can use a NN with prior weights in your exe.


On Wed, 12 Mar 2008 04:42:01 -0400, Blueblood Kingroyale
<edproject.cec@gmail.com> wrote:

> Hey thanks Ashish,
> the link(http://www.mathworks.com/support/solutions/data/1-
> 15YVJB.html) you sent did help me to identify the problem
> in a better way but I'm yet to find a solution.
>
> 'sim' function in the Neural Network toolbox is in the
> list of unsupported functions (that can't be converted to
> stand alone by mcc) somebody please explain how
> can 'pragma'; that is %#function; be used to solve this
> problem.

Subject: 'sim' unsupported for standalone

From: Blueblood Kingroyale

Date: 12 Mar, 2008 14:30:22

Message: 5 of 12

Hi Ashish, really do appreciate your inputs here.
So maybe I should get used to the hard fact of life that I
cant have 'sim' and the .exe at the same time. Now check
this - I am using sim to train the network before I use it.
But to get the output of the Neural Network during run time
(upon presenting a dynamic input) I will need sim again,
won't I ? Or is there any other way to use a pre-trained
Neural Network?

Subject: 'sim' unsupported for standalone

From: Ashish Uthama

Date: 12 Mar, 2008 14:46:30

Message: 6 of 12

gah. sorry for the confusion.

You should be able to use sim, gensim is the one not supported for
deployment (EXE) I guess.

so you were right, have to use function pragma,

The earlier link mentions:
%#function network

Just add this line on top of your M-file, let us know if it works.
or try
%#nnet/sim

or ..keep trying something :D

On Wed, 12 Mar 2008 10:30:22 -0400, Blueblood Kingroyale
<edproject.cec@gmail.com> wrote:

> Hi Ashish, really do appreciate your inputs here.
> So maybe I should get used to the hard fact of life that I
> cant have 'sim' and the .exe at the same time. Now check
> this - I am using sim to train the network before I use it.
> But to get the output of the Neural Network during run time
> (upon presenting a dynamic input) I will need sim again,
> won't I ? Or is there any other way to use a pre-trained
> Neural Network?

Subject: 'sim' unsupported for standalone

From: Ashish Uthama

Date: 12 Mar, 2008 14:47:11

Message: 7 of 12

the sim in the list of unsupported function might be referring to the
simulink 'sim' command.

On Wed, 12 Mar 2008 10:46:30 -0400, Ashish Uthama <ashishu@ece.ubc.ca>
wrote:

> gah. sorry for the confusion.
>
> You should be able to use sim, gensim is the one not supported for
> deployment (EXE) I guess.
>
> so you were right, have to use function pragma,
>
> The earlier link mentions:
> %#function network
>
> Just add this line on top of your M-file, let us know if it works.
> or try
> %#nnet/sim
>
> or ..keep trying something :D
>
> On Wed, 12 Mar 2008 10:30:22 -0400, Blueblood Kingroyale
> <edproject.cec@gmail.com> wrote:
>
>> Hi Ashish, really do appreciate your inputs here.
>> So maybe I should get used to the hard fact of life that I
>> cant have 'sim' and the .exe at the same time. Now check
>> this - I am using sim to train the network before I use it.
>> But to get the output of the Neural Network during run time
>> (upon presenting a dynamic input) I will need sim again,
>> won't I ? Or is there any other way to use a pre-trained
>> Neural Network?
>

Subject: Pragma is the answer!!!

From: Blueblood Kingroyale

Date: 13 Mar, 2008 06:24:01

Message: 8 of 12

Hi Ashish,

Thanks a lot for your help the %#function network thing
worked out great. We were able to create the .exe after
adding that line to our code.

Another small little doubt: can we have Windows API calls
from within MATLAB itself? Any info on that would be
really welcome. Gracias once again.

Blueblood.

Subject: Pragma is the answer!!!

From: Ashwini Deshpande

Date: 13 Mar, 2008 07:21:02

Message: 9 of 12

"Blueblood Kingroyale" <edproject.cec@gmail.com> wrote in
message <fraha1$ogg$1@fred.mathworks.com>...
> Hi Ashish,
>
> Thanks a lot for your help the %#function network thing
> worked out great. We were able to create the .exe after
> adding that line to our code.
>
> Another small little doubt: can we have Windows API calls
> from within MATLAB itself? Any info on that would be
> really welcome. Gracias once again.
>
> Blueblood.
Hey,
i am also facing the same problem..
I am not able to follow the postings here for ur query ..
If u have understood, can u plz write a sample program and
post it.
From so many days i am struggling for this ... Kindly post it.

Thanks,
Ashwini
    

Subject: Pragma is the answer!!!

From: Blueblood Kingroyale

Date: 14 Mar, 2008 05:45:03

Message: 10 of 12

Hi Ashwini,

Dont know exactly what your looking for. Our prob was that
the sim function (NN Toolbox) is unsupported and cant be
used in an m file that is to be converted to a standalone
(exe).
All I did was add the line "%#function network" at the top
of the code in that m file.
That solved the problem.
Hope this helps.

Blueblood

Subject: Pragma is the answer!!!

From: Ashwini Deshpande

Date: 14 Mar, 2008 08:36:02

Message: 11 of 12

"Blueblood Kingroyale" <edproject.cec@gmail.com> wrote in
message <frd3cu$duf$1@fred.mathworks.com>...
> Hi Ashwini,
>
> Dont know exactly what your looking for. Our prob was that
> the sim function (NN Toolbox) is unsupported and cant be
> used in an m file that is to be converted to a standalone
> (exe).
> All I did was add the line "%#function network" at the top
> of the code in that m file.
> That solved the problem.
> Hope this helps.
>
> Blueblood

Hi,
Let me explain u about my requirement, i have a m-file and
simulink model. i am passing some parameters to simulink
model using assignin command and want to run the model from
the m-file using sim command and want to see the result in
base workspace. Have a look at the following code, it may
give some idea:

function m_file
a = 12; b = 23;
assignin('base','a',a);
assignin('base','b',b);
sim('sim_mdl');
evalin('base','a');
evalin('base','b');

simout;
timeout;

sim_mdl codel contains 2 constant blocks for which a and b
parameters are assigned and after some calculation say
addition, the sum has to be saved to workspace using 'To
Workspace' block.

can u pls suggest me any way to make it standalone.

Thanks a lot for ur reply,
Regards,
Ashwini

 

Subject: Pragma is the answer!!!

From: Ashish Uthama

Date: 14 Mar, 2008 13:56:32

Message: 12 of 12

clarification based on my understanding:

sim (Simulink) command cannot be compiled.

sim (neural network) command can be compiled. However, to make sure that=
  =

the compiler
undertands that we are using the NN toolbox command and not the Simulink=
  =

command we use
the compiler directive.


The pragma directive is not something which converts a non-compilable =

function to a compilable one.


On Fri, 14 Mar 2008 04:36:02 -0400, Ashwini Deshpande =

<vd.ashwini@mathworks.com> wrote:

> "Blueblood Kingroyale" <edproject.cec@gmail.com> wrote in
> message <frd3cu$duf$1@fred.mathworks.com>...
>> Hi Ashwini,
>>
>> Dont know exactly what your looking for. Our prob was that
>> the sim function (NN Toolbox) is unsupported and cant be
>> used in an m file that is to be converted to a standalone
>> (exe).
>> All I did was add the line "%#function network" at the top
>> of the code in that m file.
>> That solved the problem.
>> Hope this helps.
>>
>> Blueblood
>
> Hi,
> Let me explain u about my requirement, i have a m-file and
> simulink model. i am passing some parameters to simulink
> model using assignin command and want to run the model from
> the m-file using sim command and want to see the result in
> base workspace. Have a look at the following code, it may
> give some idea:
>
> function m_file
> a =3D 12; b =3D 23;
> assignin('base','a',a);
> assignin('base','b',b);
> sim('sim_mdl');
> evalin('base','a');
> evalin('base','b');
>
> simout;
> timeout;
>
> sim_mdl codel contains 2 constant blocks for which a and b
> parameters are assigned and after some calculation say
> addition, the sum has to be saved to workspace using 'To
> Workspace' block.
>
> can u pls suggest me any way to make it standalone.
>
> Thanks a lot for ur reply,
> Regards,
> Ashwini
>
>

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
api calls Blueblood Kingroyale 13 Mar, 2008 02:25:15
neural network ... Blueblood Kingroyale 12 Mar, 2008 10:35:06
sim Blueblood Kingroyale 12 Mar, 2008 10:35:06
sim function Blueblood Kingroyale 12 Mar, 2008 04:45:11
pragma Blueblood Kingroyale 12 Mar, 2008 04:45:10
exe conversion Blueblood Kingroyale 11 Mar, 2008 08:10:20
rssFeed for this Thread

Contact us at files@mathworks.com