MATLAB Answers


How can I use speed up Matlab?

Asked by Ayob
on 26 Apr 2013

I have a large program with a plenty of data and whenever I run Matlab on my program it takes a lot to do it. I checked my CPU usage in windows task bar manager. It never gets over 50 percent and stays something around 50%, sometimes 51 or 49% . I think I can speed up Matlab calculating by let it have 90 or 95 percent of my CPU usage. I don't know how can I set this property on Matlab and my PC.

Note: I'm using windows vista on LG laptop.


Do you happen to have a dual core processor?

What kind of processing are you doing? Are you using vectorization a lot on large matrices? Which MATLAB release are you using?

on 26 Apr 2013

Yes,I have a Intel dual core processor. I'm making a big matrix from smaller ones what is called matrix assembling but I think it's not important what I'm doing. I just want to have much CPU usage.


No products are associated with this question.

2 Answers

Answer by Jason Ross
on 26 Apr 2013

If your CPU uses hyper-threading, the OS is reporting the number of virtual cores, which are typically twice the number of execution cores. Math operations will require the execution cores and will therefore look as if the system is only half busy.

If you turn off hyper-threading in the BIOS, I bet your CPU utilization climbs to the percentage you want, although the execution time of your code will likely stay the same.


Answer by Walter Roberson
on 26 Apr 2013

Your CPU percentage might reflect that only one of your two cores is engaged in the work. In certain cases, MATLAB will automatically use multiple cores even if the user does not have the Parallel Computing Toolkit, but those cases are based upon doing mathematical operations on large vectors or arrays (usually around 9000 or more elements.)

I cannot determine at the moment whether your task would be suitable for parallel processing even if you had the Parallel Computing Toolkit, but it might be.

You should profile your code to determine where the bottlenecks are. You should ensure that you pre-allocate your matrices when computationally practical. These are unlikely not engage the second core automatically, but they have the potential for improving the efficiency of your single-core computation.


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!