jeudi 29 septembre 2016

how to improve performance of my (if-statment) in matlab

I have the following code in my Matlab function which runs 8 million times. each line takes about two seconds. is there a way to improve this?

result = msum(row_end, col_end);
if row_start  ~= 1
    result = result - msum(row_start - 1, col_end);
end
if col_start  ~= 1
    result = result - msum(row_end, col_start - 1);
end
if row_start ~=1 && col_start ~= 1
    result = result + msum(row_start - 1, col_start - 1);
end

Aucun commentaire:

Enregistrer un commentaire