loops - MATLAB: Faster pre-allocation of zeros-matrix -
this question has answer here:
/edit: see here interesting discussion of topic. @dan
using a(m,n) = 0 appears faster, depending of size of matrix a, a = zeros(m,n). both variants same when comes pre-allocation before loop?
they definately not same.
though there ways beat performance of a=zeros(m,n), doing a(m,n) = 0 not safe way it. if entries in a exist keep existing.
see this nice options, consider doing loop backwards if don't mind risk.
Comments
Post a Comment