Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Reducing the time for MATLAB code

Reducing the time for MATLAB code

Reducing the time for MATLAB code

Hello, I am working on a code on MATLAB 7.0. It takes me about 5 hours for my program to run once.

I am working on optimization, so I have some functions that are called thousands of times.

I read about vectorizing the code, but im dealing with sophisticated loops and im not sure if they can be vectorized.

I also tried to run the profiler, and I analyzed the function taking most of the time.

For example, it says 35 secs for "other lines and overhead" and i was wondering if i can do something to reduce this time.

Other lines in my function dont take much time relative to the 35 secs mentioned above.

I can post the results obtained in the profiler if it helps.

Thank you for any help.


RE: Reducing the time for MATLAB code


Thanks for your reply.

35 secs for running the function once.

The code runs 200 times in order to perform optimization, and each time it runs the function itself gets called more than once. So 35 secs which initially seems a very small time becomes 35secs x 200 x no. of calls per 1 loop.


RE: Reducing the time for MATLAB code

Optimization of existing code usually translates into at best 2x improvement?  You need more like 100x improvement, which means completely rethinking your approach.

It sounds like you're running your own solver loop, which is usually going to be pathetic in performance compared to built-in functions.


FAQ731-376: Eng-Tips.com Forum Policies

RE: Reducing the time for MATLAB code


Yes, the functions Im using arent built-in. What I wanted to know is whether the time taken for "other lines and overhead" can be reduced or no. I dont even know what overhead is. It is taking %87 of the function time.


RE: Reducing the time for MATLAB code

Yes, but you're only going to get a factor of 2 or so in performance improvement, because you are limited to using function calls, while the built-in solver functions use native code.

One possibility is to compile the code; that might make it somewhat faster.


FAQ731-376: Eng-Tips.com Forum Policies

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close