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

New to MATLAB?

Thread Subject:
vectorization - speed up

Subject: vectorization - speed up

From: francesco santi

Date: 3 Mar, 2009 09:55:04

Message: 1 of 2

I need to speed up this function.
It is executed many times in my algorithm and it runs on big matrix.
I have used the profiler and it is the most called and the most time consuming function.
Any help would be appreciated.

function Singleton = singleton(classes, Parameters, ImageMatrix)
global HSV_rows HSV_cols

Singleton = cell(1,classes);
for l=1:classes
    temp = zeros(HSV_rows, HSV_cols);
    detSl = Parameters(l).DetermS;
    temp2 = -log(1/(sqrt(power(2*pi,3)*detSl)));
    Ml = Parameters(l).Med;
    invSl = Parameters(l).InverS;
    for r=1:HSV_rows
        for c=1:HSV_cols
            fl = double(cell2mat(ImageMatrix(r,c)));
            temp(r,c) = (fl - Ml) * invSl * (fl - Ml)';
    Singleton{l} = real(temp2+temp*.5);

Thank you very much in advance for any kind of help,

Subject: vectorization - speed up

From: us

Date: 3 Mar, 2009 10:10:17

Message: 2 of 2

"francesco santi"
> fl = double(cell2mat(ImageMatrix(r,c)));

this syntax lets CSSMers assume that ImageMatrix itself contains r x c CELLS...
if this is correct
- what is the size of each CELL...
- are they of equal sizes...


Tags for this Thread

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.

Contact us