<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100</link>
    <title>MATLAB Central Newsreader - much faster MATLAB</title>
    <description>Feed for thread: much faster MATLAB</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 07 Oct 2008 00:47:03 -0400</pubDate>
      <title>much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604012</link>
      <author>Kevin Johnson</author>
      <description>All,&lt;br&gt;
&lt;br&gt;
I have been using MATLAB for many years now but finally its speed has become a major limiting factor.  As time has gone on, large segments of my code are no longer in need of further development (though other segments are). These same segments are the ones that consume most of the computation time. &lt;br&gt;
&lt;br&gt;
Mex files are the solution I suppose; however the last time I programmed in Fortran was 30 years ago, and in C, never. In reading about mex files, it sounds daunting for a basically amateur (in terms of skills) programmer like me. &lt;br&gt;
&lt;br&gt;
In a broad sense, what would be the best approach to substantially (at least 10x) speed up these unchanging swaths of code, for someone who is not a programmer?  I'd be able to invest in a solution within reason.&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;
&lt;br&gt;
&amp;nbsp;</description>
    </item>
    <item>
      <pubDate>Tue, 07 Oct 2008 03:10:24 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604023</link>
      <author>Rodney Thomson</author>
      <description>&quot;Kevin Johnson&quot; &amp;lt;defer.jof@gmail.com&amp;gt; wrote in message &amp;lt;gcebi7$otk$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; All,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have been using MATLAB for many years now but finally its speed has become a major limiting factor.  As time has gone on, large segments of my code are no longer in need of further development (though other segments are). These same segments are the ones that consume most of the computation time. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Mex files are the solution I suppose; however the last time I programmed in Fortran was 30 years ago, and in C, never. In reading about mex files, it sounds daunting for a basically amateur (in terms of skills) programmer like me. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; In a broad sense, what would be the best approach to substantially (at least 10x) speed up these unchanging swaths of code, for someone who is not a programmer?  I'd be able to invest in a solution within reason.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  &lt;br&gt;
&lt;br&gt;
Mex files are not always the solution. Improving the MATLAB implementation can offer orders of magnitude increase in performance when a particularly poor choice has been made (ie arrays growing in loops etc).&lt;br&gt;
&lt;br&gt;
I would recommend that you run your code through the MATLAB Profiler and identify the regions of poorly performing code. Look at any MLint messages from those code blocks, try and find more efficient implementations of the algorithms.&lt;br&gt;
&lt;br&gt;
And sometimes it just takes a certain period of time to do particular operations independent of the implementation language. In that case, buy a faster CPU!&lt;br&gt;
&lt;br&gt;
Cheers&lt;br&gt;
&lt;br&gt;
Rod&lt;br&gt;
&lt;br&gt;
--&lt;br&gt;
&lt;a href=&quot;http://iheartmatlab.blogspot.com&quot;&gt;http://iheartmatlab.blogspot.com&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Tue, 07 Oct 2008 13:52:00 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604131</link>
      <author>REIDAR</author>
      <description>On Oct 6, 11:10=A0pm, &quot;Rodney Thomson&quot;&lt;br&gt;
&amp;lt;readm...@iheartmatlab.blogspot.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &quot;Kevin Johnson&quot; &amp;lt;defer....@gmail.com&amp;gt; wrote in message &amp;lt;gcebi7$ot...@fred=&lt;br&gt;
.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; All,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I have been using MATLAB for many years now but finally its speed has b=&lt;br&gt;
ecome a major limiting factor. =A0As time has gone on, large segments of my=&lt;br&gt;
&amp;nbsp;code are no longer in need of further development (though other segments a=&lt;br&gt;
re). These same segments are the ones that consume most of the computation =&lt;br&gt;
time.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Mex files are the solution I suppose; however the last time I programme=&lt;br&gt;
d in Fortran was 30 years ago, and in C, never. In reading about mex files,=&lt;br&gt;
&amp;nbsp;it sounds daunting for a basically amateur (in terms of skills) programmer=&lt;br&gt;
&amp;nbsp;like me.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; In a broad sense, what would be the best approach to substantially (at =&lt;br&gt;
least 10x) speed up these unchanging swaths of code, for someone who is not=&lt;br&gt;
&amp;nbsp;a programmer? =A0I'd be able to invest in a solution within reason.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Mex files are not always the solution. Improving the MATLAB implementatio=&lt;br&gt;
n can offer orders of magnitude increase in performance when a particularly=&lt;br&gt;
&amp;nbsp;poor choice has been made (ie arrays growing in loops etc).&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I would recommend that you run your code through the MATLAB Profiler and =&lt;br&gt;
identify the regions of poorly performing code. Look at any MLint messages =&lt;br&gt;
from those code blocks, try and find more efficient implementations of the =&lt;br&gt;
algorithms.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; And sometimes it just takes a certain period of time to do particular ope=&lt;br&gt;
rations independent of the implementation language. In that case, buy a fas=&lt;br&gt;
ter CPU!&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Cheers&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Rod&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; --&lt;a href=&quot;http://iheartmatlab.blogspot.com&quot;&gt;http://iheartmatlab.blogspot.com&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
Rod's probably right here.  If you spend a little time to learn&lt;br&gt;
Matlab's logical indexing and linearizing methods, you can write&lt;br&gt;
wicked fast code, without having to resort to a compiled language.&lt;br&gt;
However, if you'd rather dip into Fortran and C, knock yourself out.</description>
    </item>
    <item>
      <pubDate>Tue, 07 Oct 2008 14:33:20 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604142</link>
      <author>Rune Allnor</author>
      <description>On 7 Okt, 02:47, &quot;Kevin Johnson&quot; &amp;lt;defer....@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; All,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have been using MATLAB for many years now but finally its speed has bec=&lt;br&gt;
ome a major limiting factor. =A0As time has gone on, large segments of my c=&lt;br&gt;
ode are no longer in need of further development (though other segments are=&lt;br&gt;
). These same segments are the ones that consume most of the computation ti=&lt;br&gt;
me.&lt;br&gt;
&lt;br&gt;
You might want to profile the code and see exactky where the&lt;br&gt;
bottlenecks are. After that, you might want to look into the&lt;br&gt;
time-consuming parts and see what goes on in there. If they&lt;br&gt;
are plain-vanilla matrix operations there is likely not much&lt;br&gt;
you can do to speed things up - you might possibly gain something&lt;br&gt;
by using parallel libraries in a multi-core CPU, depending on&lt;br&gt;
your present hardware. If you findbottlenecks in I/O, work flow&lt;br&gt;
organization etc, you can expect 10x improvment if you switch&lt;br&gt;
to a language like C++.&lt;br&gt;
&lt;br&gt;
&amp;gt; Mex files are the solution I suppose; however the last time I programmed =&lt;br&gt;
in Fortran was 30 years ago, and in C, never. In reading about mex files, i=&lt;br&gt;
t sounds daunting for a basically amateur (in terms of skills) programmer l=&lt;br&gt;
ike me.&lt;br&gt;
&lt;br&gt;
It's for sure not something to be taken lightly. On the&lt;br&gt;
other hand, you will not find any better motivation to&lt;br&gt;
learn than your present frustration.&lt;br&gt;
&lt;br&gt;
&amp;gt; In a broad sense, what would be the best approach to substantially (at le=&lt;br&gt;
ast 10x) speed up these unchanging swaths of code, for someone who is not a=&lt;br&gt;
&amp;nbsp;programmer? =A0I'd be able to invest in a solution within reason.&lt;br&gt;
&lt;br&gt;
If you are not a programmer by training yourself, then you&lt;br&gt;
might want to consult somebody who is. It takes time and&lt;br&gt;
dedication to learn how to program efficiently, and it might&lt;br&gt;
be too large a commitment to take on, if you only want to&lt;br&gt;
modify some existing code.&lt;br&gt;
&lt;br&gt;
If somebody seriously considers to learn Fortran or C in order&lt;br&gt;
to program MEX files, I would suggest they consider C++. It is&lt;br&gt;
a far more flexible language than either Fortran or C, so one&lt;br&gt;
can do far more advanced stuff, and everything is way easier.&lt;br&gt;
&lt;br&gt;
The downside with C++ is that one needs a C++ compiler to use&lt;br&gt;
with matlab (matlab comes with a C compiler), and C++ takes&lt;br&gt;
a long time to learn.&lt;br&gt;
&lt;br&gt;
Rune</description>
    </item>
    <item>
      <pubDate>Tue, 07 Oct 2008 15:26:02 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604165</link>
      <author>Kevin Johnson</author>
      <description>Rune and Rod,&lt;br&gt;
&lt;br&gt;
First of all, thank you very much for taking the time to answer.&lt;br&gt;
&lt;br&gt;
I run Profiler routinely to look for bottlenecks and have indeed found many.  I also have vectorized for loops where I can figure out how to do so.&lt;br&gt;
&lt;br&gt;
Would it be correct to say that where CPU usage is the problem, only a faster CPU (or parallel computing) would help, whereas with most everything else mex files would be substantially faster?&lt;br&gt;
&lt;br&gt;
How would I go about finding a professional programmer to help me, if it comes to that?&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;
Kevin</description>
    </item>
    <item>
      <pubDate>Tue, 07 Oct 2008 15:55:48 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604171</link>
      <author>Rune Allnor</author>
      <description>On 7 Okt, 17:26, &quot;Kevin Johnson&quot; &amp;lt;defer....@gmail.com&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; Would it be correct to say that where CPU usage is the problem, only a faster CPU (or parallel computing) would help, whereas with most everything else mex files would be substantially faster?&lt;br&gt;
&lt;br&gt;
Yes, but be aware that the CPU probably works flat out&lt;br&gt;
already, regardless of what causes the bottleneck. You&lt;br&gt;
might not be able to identify improvable code very&lt;br&gt;
easily.&lt;br&gt;
&lt;br&gt;
&amp;gt; How would I go about finding a professional programmer to help me, if it comes to that?&lt;br&gt;
&lt;br&gt;
I have no idea.&lt;br&gt;
&lt;br&gt;
Rune</description>
    </item>
    <item>
      <pubDate>Tue, 07 Oct 2008 17:00:37 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604189</link>
      <author>Walter Roberson</author>
      <description>Kevin Johnson wrote:&lt;br&gt;
&amp;nbsp;&lt;br&gt;
&amp;gt; Would it be correct to say that where CPU usage is the problem, only a faster CPU (or&lt;br&gt;
&amp;gt; parallel computing) would help, whereas with most everything else mex files would be&lt;br&gt;
&amp;gt; substantially faster?&lt;br&gt;
&lt;br&gt;
No, I wouldn't say so. If you are I/O bound, for example, then with a MEX file you&lt;br&gt;
are -still- going to be I/O bound (though with some operating systems and for some&lt;br&gt;
kinds of data access patterns, you might be able to use &quot;scatter/gather I/O&quot;&lt;br&gt;
to improve I/O performance.) &lt;br&gt;
&lt;br&gt;
These days, with Matlab's Just In Time (JIT) compiler, Matlab might not be as&lt;br&gt;
fast as a really good optimizing compiler, but when the operations have been&lt;br&gt;
chosen wisely, it is often better than &quot;plain&quot; C or C++ that has not been&lt;br&gt;
specifically designed for high performance.&lt;br&gt;
&lt;br&gt;
C or C++ code that -has- been specifically designed for high performance has to&lt;br&gt;
rely upon system-specific knowledge or extensions: the C and C++ programming&lt;br&gt;
languages describe abstract operation models and have no inherent mechanisms to&lt;br&gt;
(for example) say &quot;Allocate two blocks of memory for me, both such and such a&lt;br&gt;
size, but align them in such a way that if I access them both sequentially with&lt;br&gt;
a stride of such-and-such, that I will not have any cache line collisions between the&lt;br&gt;
two arrays&quot;. And the C and C++ languages do not have ways to express,&lt;br&gt;
&quot;Compile the following block of code so that the floating point operations are&lt;br&gt;
done on a SSE3 co-processor.&quot; Thus high-performance C or C++ code is not portable&lt;br&gt;
code: you have to cheat on the promises made by the programming languages in order&lt;br&gt;
to get the performance.&lt;br&gt;
&lt;br&gt;
The potential performance difference between MATLAB and C or C++ is based upon&lt;br&gt;
the fact that MATLAB hides all of its performance tricks under the covers, whereas&lt;br&gt;
when you use C or C++ you have an opportunity to make them explicit. For example, does&lt;br&gt;
MATLAB take cache effects into account when calculating A+B for matrices? You don't&lt;br&gt;
know and you can't find out, not unless you know that whatever operation you are doing&lt;br&gt;
is handed over to BLAS and you have the BLAS source available along with the list&lt;br&gt;
of options that BLAS was compiled with for your particular processor. But lack&lt;br&gt;
of information about what MATLAB is doing to maintain performance doesn't mean that&lt;br&gt;
MATLAB is -not- taking measures to optimize performance: it just means you don't know&lt;br&gt;
-what- measures it is taking, and the measures might change from version to version&lt;br&gt;
(possibly making some situations worse instead of better.)</description>
    </item>
    <item>
      <pubDate>Tue, 07 Oct 2008 18:55:32 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604203</link>
      <author>tristram.scott@ntlworld.com (Tristram Scott)</author>
      <description>Kevin Johnson &amp;lt;defer.jof@gmail.com&amp;gt; wrote:&lt;br&gt;
[snip]&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Would it be correct to say that where CPU usage is the problem, only a&lt;br&gt;
faster CPU (or parallel computing) would help, whereas with most everything&lt;br&gt;
else mex files would be substantially faster?&lt;br&gt;
&lt;br&gt;
No.  See other peoples comments for some good points on this.&lt;br&gt;
&lt;br&gt;
You are not going to get any specific answers, though, unless you share&lt;br&gt;
some specific code.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; How would I go about finding a professional programmer to help me, if it&lt;br&gt;
comes to that?&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
You could drop me an email with some more details.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Dr Tristram J. Scott               &lt;br&gt;
Energy Consultant                  </description>
    </item>
    <item>
      <pubDate>Tue, 07 Oct 2008 19:11:01 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604207</link>
      <author>Steve Amphlett</author>
      <description>&quot;Kevin Johnson&quot; &amp;lt;defer.jof@gmail.com&amp;gt; wrote in message &amp;lt;gcebi7$otk$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; All,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have been using MATLAB for many years now but finally its speed has become a major limiting factor.  As time has gone on, large segments of my code are no longer in need of further development (though other segments are). These same segments are the ones that consume most of the computation time. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Mex files are the solution I suppose; however the last time I programmed in Fortran was 30 years ago, and in C, never. In reading about mex files, it sounds daunting for a basically amateur (in terms of skills) programmer like me. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; In a broad sense, what would be the best approach to substantially (at least 10x) speed up these unchanging swaths of code, for someone who is not a programmer?  I'd be able to invest in a solution within reason.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Some additional comments that may be relevant.&lt;br&gt;
&lt;br&gt;
Files: Matlab didn't use to be that clever at file I/O.  Or at data types other than double precision. Given some random file to read (e.g. from a simulation program or data analyser), MEX was the only sensible option.  That may have changed now - I've not recently tried to read in huge amounts of data from a binary file.  Many vendors will provide you with A C API to read their files, pretty much forcing you to use MEX.&lt;br&gt;
&lt;br&gt;
Memory: Most data analysis I used to do involved very large datasets.  The analysis was usually limited my memory.  Fine-grained control over memory use was something that was absolutely necessary, but not possible with Matlab - too many intermediate copies of variables.  To a certain extent, this is still true today.&lt;br&gt;
&lt;br&gt;
System interaction:  If you want access to base OS functions, you need to code in their language.  In the UNIX environment, this is C.  What you are really doing is extending Matlab rather than simply making it faster.&lt;br&gt;
&lt;br&gt;
As far as speed goes, I've never really been involved with matrix maths.  Most of my analysis is/was with very long 1D arrays.  It was always simple to get good speedup over the built-in functions.  Massive if you &quot;crossed to the dark side&quot; and started to modify things you weren't supposed to.&lt;br&gt;
&lt;br&gt;
An anecdote:  One of our departments based its whole analysis core on a load of MEX functions, using simple m-file scripts to shovel data between them.  The original author left many years ago, leaving them unsupported and to a large extend, not even understood (neither the theory nor implementation).  After a few years with their heads in the sand they seem to have decided to go back to the safer position of using MEX only where required rather than for fun.&lt;br&gt;
&lt;br&gt;
My view: MEX files should not be used unless there is a competent (hopefully better than that) C programmer on board, preferably more than one (see above).  Outsourcing them sounds like a suicidal tactic.</description>
    </item>
    <item>
      <pubDate>Tue, 07 Oct 2008 19:54:19 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604215</link>
      <author>Ralph Schleicher</author>
      <description>&quot;Kevin Johnson&quot; &amp;lt;defer.jof@gmail.com&amp;gt; writes:&lt;br&gt;
&lt;br&gt;
&amp;gt; How would I go about finding a professional programmer to help me, if&lt;br&gt;
&amp;gt; it comes to that?&lt;br&gt;
&lt;br&gt;
If money is not an issue, you should't have problems with that.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Ralph Schleicher  &amp;lt;&lt;a href=&quot;http://ralph-schleicher.de&quot;&gt;http://ralph-schleicher.de&lt;/a&gt;&amp;gt;&lt;br&gt;
&lt;br&gt;
Development * Consulting * Training&lt;br&gt;
Mathematical Modeling and Simulation&lt;br&gt;
Software Tools</description>
    </item>
    <item>
      <pubDate>Tue, 07 Oct 2008 21:28:01 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604229</link>
      <author>Charles Cuell</author>
      <description>&quot;Kevin Johnson&quot; &amp;lt;defer.jof@gmail.com&amp;gt; wrote in message &amp;lt;gcebi7$otk$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; All,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have been using MATLAB for many years now but finally its speed has become a major limiting factor.  As time has gone on, large segments of my code are no longer in need of further development (though other segments are). These same segments are the ones that consume most of the computation time. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Mex files are the solution I suppose; however the last time I programmed in Fortran was 30 years ago, and in C, never. In reading about mex files, it sounds daunting for a basically amateur (in terms of skills) programmer like me. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; In a broad sense, what would be the best approach to substantially (at least 10x) speed up these unchanging swaths of code, for someone who is not a programmer?  I'd be able to invest in a solution within reason.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Also, consider the possibility that writing, debugging, testing, debugging, optimizing, debugging, and running C++ code may actually take longer than just waiting for the Matlab code to run.&lt;br&gt;
&lt;br&gt;
If I knew then what I know now, I wouldn't know anything about C++ and I'd be a year younger.&lt;br&gt;
&lt;br&gt;
Charles&lt;br&gt;
&amp;gt;  </description>
    </item>
    <item>
      <pubDate>Thu, 09 Oct 2008 13:53:05 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604321</link>
      <author>Qun HAN</author>
      <description>&quot;Kevin Johnson&quot; &amp;lt;defer.jof@gmail.com&amp;gt; wrote in message &amp;lt;gcebi7$otk$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; All,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have been using MATLAB for many years now but finally its speed has become a major limiting factor.  As time has gone on, large segments of my code are no longer in need of further development (though other segments are). These same segments are the ones that consume most of the computation time. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Mex files are the solution I suppose; however the last time I programmed in Fortran was 30 years ago, and in C, never. In reading about mex files, it sounds daunting for a basically amateur (in terms of skills) programmer like me. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; In a broad sense, what would be the best approach to substantially (at least 10x) speed up these unchanging swaths of code, for someone who is not a programmer?  I'd be able to invest in a solution within reason.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
matlab2fmex would be an useful tool that help you turn your MATLAB code to Fortran MEX &quot;automatically&quot;. &lt;br&gt;
You can find it at https://sourceforge.net/projects/matlab2fmex/</description>
    </item>
    <item>
      <pubDate>Thu, 09 Oct 2008 13:53:11 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604357</link>
      <author>Jiro Doke</author>
      <description>&quot;Kevin Johnson&quot; &amp;lt;defer.jof@gmail.com&amp;gt; wrote in message &amp;lt;gcebi7$otk$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; All,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have been using MATLAB for many years now but finally its speed has become a major limiting factor.  As time has gone on, large segments of my code are no longer in need of further development (though other segments are). These same segments are the ones that consume most of the computation time. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Mex files are the solution I suppose; however the last time I programmed in Fortran was 30 years ago, and in C, never. In reading about mex files, it sounds daunting for a basically amateur (in terms of skills) programmer like me. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; In a broad sense, what would be the best approach to substantially (at least 10x) speed up these unchanging swaths of code, for someone who is not a programmer?  I'd be able to invest in a solution within reason.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  &lt;br&gt;
&lt;br&gt;
There's also Embedded MATLAB that you can use to generate C code or a C-MEX file directly from a subset of MATLAB commands.&lt;br&gt;
&lt;br&gt;
Embedded MATLAB&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/eml/eml_product_page.html&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/eml/eml_product_page.html&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
(Embedded MATLAB MEX)&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/eml/ug/bq2wkmb-1.html&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/eml/ug/bq2wkmb-1.html&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
If you're not concerned about getting the actual C-code, and just want a C-MEX file, then you can go with Embedded MATLAB MEX, which would require either Simulink and/or Fixed-Point Toolbox.&lt;br&gt;
&lt;br&gt;
Here's where it talks about the Embedded MATLAB subset:&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/eml/ug/bq1h2z5-1.html&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/eml/ug/bq1h2z5-1.html&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Thu, 09 Oct 2008 13:53:24 -0400</pubDate>
      <title>Re: much faster MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237100#604426</link>
      <author>Sebastiaan </author>
      <description>I disagree with the general opinion that it is hard to make faster code with MEX files. Matlab does not handle some cases efficiently. &lt;br&gt;
&lt;br&gt;
For example, when working with large matrices:&lt;br&gt;
A = zeros(n, n);&lt;br&gt;
for j=1:many&lt;br&gt;
&amp;nbsp;&amp;nbsp;B = sparse(n, n, 0.01);&lt;br&gt;
&amp;nbsp;&amp;nbsp;A = A + B;&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
So, adding a sparse matrix to a full matrix, many times. Matlab first creates a temporary matrix T = A+B, and then assigns A:=T, deleting the previous A from memory. For large matrices, this reallocating consumes considerable time.&lt;br&gt;
&lt;br&gt;
Writing a simple MEX file that overwrites the data in A:&lt;br&gt;
MexAddMatrix(A,B);&lt;br&gt;
bypasses the memory allocation for A.&lt;br&gt;
&lt;br&gt;
MEX files can also speedup many elementary numerical work, e.g. raytraycing.&lt;br&gt;
&lt;br&gt;
Greetings,&lt;br&gt;
Sebastiaan</description>
    </item>
  </channel>
</rss>

