Matlab Programming
Logical indexing
Save time to avoid loop.
Preallocation
time
tic;sum(1:1e3);toc
Save time to avoid allocate every time.
A = zeros(N,N); If no preallocation, every time matrix A change size.
Save time to avoid loop.
tic;sum(1:1e3);toc
Save time to avoid allocate every time.
A = zeros(N,N); If no preallocation, every time matrix A change size.