Tags: badenglish, contains, convert, directly, execute, expect, foreigner, ignorance, loops, matlab, mex-file, programming, script, user

How to convert directly from .m to mex-file

On Programmer » Matlab

5,433 words with 4 Comments; publish: Wed, 07 May 2008 21:30:00 GMT; (20070.31, « »)

Hi, I am a foreigner beginer user so i expect my ignorance and my bad

english will be pardoned.

I am trying to execute a script which contains loops and graphics.

Well, with my poor computer I waste more of an hour trying to get

results. So i want to split the loops from the graphics. The graphics

would remain into the .m file meanwhile I'd make two functions in .m

files with the loops. For improving the execution time, i thought to

convert the .m functions in mex files which can be used by the

graphic .m file. My question would be :

How can i convert DIRECTLY from .m files to mex files which can be

used directly by the matlab CODE. It is important to do it DIRECTLY,

without to convert them firstly in .c and later in mex-file because

this solution has been proved and doesn't runs.

Thanks in advance and sorry for my english.

All Comments

Leave a comment...

  • 4 Comments
    • "Manuel Garcia Alonso" <majegaal.matlab.todaysummary.com.hotmail.com> wrote in message

      news:ef3c5d1.-1.matlab.todaysummary.com.webcrossing.raydaftYaTP...

      > Hi, I am a foreigner beginer user so i expect my ignorance and my bad

      > english will be pardoned.

      > I am trying to execute a script which contains loops and graphics.

      > Well, with my poor computer I waste more of an hour trying to get

      > results. So i want to split the loops from the graphics. The graphics

      > would remain into the .m file meanwhile I'd make two functions in .m

      > files with the loops. For improving the execution time, i thought to

      > convert the .m functions in mex files which can be used by the

      > graphic .m file. My question would be :

      > How can i convert DIRECTLY from .m files to mex files which can be

      > used directly by the matlab CODE. It is important to do it DIRECTLY,

      > without to convert them firstly in .c and later in mex-file because

      > this solution has been proved and doesn't runs.

      You can't. I recommend using the MATLAB Profiler to identify the bottleneck

      in the code (the section of the code that takes the longest to run) and see

      if you can make that section of code run more quickly. If you can identify

      a few (5-10) lines of code that are the bottleneck, you can try posting it

      to the newsgroup to see if the experts can optimize it.

      > Thanks in advance and sorry for my english.

      You don't need to apologize -- your message was understandable.

      Steve Lord

      slord.matlab.todaysummary.com.mathworks.com

      #1; Wed, 07 May 2008 21:31:00 GMT
    • Manuel Garcia Alonso skrev:

      > Hi, I am a foreigner beginer user so i expect my ignorance and my bad

      > english will be pardoned.

      > I am trying to execute a script which contains loops and graphics.

      > Well, with my poor computer I waste more of an hour trying to get

      > results. So i want to split the loops from the graphics. The graphics

      > would remain into the .m file meanwhile I'd make two functions in .m

      > files with the loops. For improving the execution time, i thought to

      > convert the .m functions in mex files which can be used by the

      > graphic .m file.

      As others already have mentioned, you can't get directly from

      .m to mex files. If you really want to do that conversion, you need

      to program your algorithm from scratch in one of the programming

      languages supported by the matlab API.

      Having said that, it seems as if you have two problems merged

      into one. It is usually a band idea to make one script that both

      runs the (heavy) computations, and also makes the graphics.

      It is better to make one script that runs the computatons and

      another that runs the graphics. That way, you don't have to wait

      an hour or two for the computations if all you want is to

      change the graphics.

      Of course, there is nothing to stop you from making a third script

      that calls both the computations and the graphics scripts, but

      I am sure you understand what I mean.

      Rune

      #2; Wed, 07 May 2008 21:32:00 GMT
    • Manuel Garcia Alonso wrote:

      > Hi, I am a foreigner beginer user so i expect my ignorance and my bad

      > english will be pardoned.

      > I am trying to execute a script which contains loops and graphics.

      > Well, with my poor computer I waste more of an hour trying to get

      > results. So i want to split the loops from the graphics. The graphics

      > would remain into the .m file meanwhile I'd make two functions in .m

      > files with the loops. For improving the execution time, i thought to

      > convert the .m functions in mex files which can be used by the

      > graphic .m file. My question would be :

      > How can i convert DIRECTLY from .m files to mex files which can be

      > used directly by the matlab CODE. It is important to do it DIRECTLY,

      > without to convert them firstly in .c and later in mex-file because

      > this solution has been proved and doesn't runs.

      > Thanks in advance and sorry for my english.

      Are you absolutely sure that vectorization cannot eliminate some

      of the loops?

      Hope this helps.

      Greg

      #3; Wed, 07 May 2008 21:33:00 GMT
    • Hi all.

      Thanks a lot for your answers, all them useful and accurate. My final

      decision has been to follow the logical path, that is, to vectorize

      the loops before trying any other more complex solution.

      Regards and thanks again.

      #4; Wed, 07 May 2008 21:34:00 GMT