Rank: 4781 based on 23 downloads (last 30 days) and 1 file submitted

Marc Lalancette

Toronto Hospital for Sick Children

Personal Profile:
Professional Interests:


Watch this Author's files


Files Posted by Marc
Updated   File Tags Downloads
(last 30 days)
Comments Rating
06 Feb 2014 Screenshot SurfaceSmooth Restricted smoothing of a triangulated surface Author: Marc Lalancette triangulation, surface, patch, smoothing 23 1
  • 5.0
5.0 | 1 rating
Comments and Ratings by Marc View all
Updated File Comments Rating
03 Feb 2014 Volume of a surface triangulation Given a surface triangulation, compute the volume enclosed using divergence theorem. Author: Krishnan Suresh

Nice application, but here's a cleaned up version (with V = p' and F = f'):
% 'z' coordinate of triangle centers.
FaceCentroidZ = ( V(F(:, 1), 3) + V(F(:, 2), 3) + V(F(:, 3), 3) ) /3;
% Face normal vectors, with length equal to triangle area.
FNdA = cross( (V(F(:, 2), :) - V(F(:, 1), :)), ...
(V(F(:, 3), :) - V(F(:, 2), :)) , 2 ) / 2;
% Volume from divergence theorem (using vector field along z).
V = FaceCentroidZ' * FNdA(:, 3);

03 Jul 2012 Quartile & Percentile Calculation Demonstrates a method for computing percentiles and other basic statistics. Author: Chris D. Larson

Quick and practical, but doesn't properly take into account repeated median values, e.g. [1, 2, 2, 2, 2] would have the first 3 quartiles equal to 2, but this code would give [1, 2, NaN].

23 Mar 2012 COMBN (4.3) All combinations of N elements taken from the vector V. Author: Jos (10584)

Nice code, thanks! Just for fun, slight to medium speed improvement (sorry my k = your N):

%instead of:
%[Y{k:-1:1}] = ndgrid(X) ;
%Y = reshape(cat(k+1,Y{:}),[],k) ;
%fill Y directly:
nX = numel(X);
Y(nX^k, k) = X(1); % Initialize to give shape and data type.
s(1:k-1) = {ones(1, nX)};
for i = 1:k
Y( ((i-1)*nX^k + 1) : (i*nX^k) ) = X(s{1:i-1}, :, s{i:k-1});
X = permute(X, [1:i-1, i+1, i]);
% This has inverse order for the combinations as you had, easy to change.

22 Mar 2012 NCHOOSE (v2.1 mar 2010) return all combinations of the elements of a set Author: Jos (10584)

Theoretical note, in case someone (as I did) wants to get a limited number of random combinations, then this method fails for N > 51 since then eps(2^52) = 1, i.e. can't represent the integers accurately any more with double type. Of course, here we run out of memory with such a large N anyway.

Also, with bitget, I was using a loop over bits instead of a loop over combinations. I haven't checked, but I assumed it would be faster. I'm also going to check with d2b instead of bitget. (found on FEX, and modified to work on arrays).

22 Mar 2012 Efficient convertors between binary and decimal numbers Alternatives to the built-in functions bin2dec & dec2bin, exhibiting a somewhat faster performance. Author: Zacharias Voulgaris

Actually, the bug was for any power of 2 (1, 2, 4, ...). Ali's modification works, but a more elegant fix is:
c = floor(log2(x)) + 1;
No need for any other modification from original code (no special case for 1, no need to remove preceding zeros).

Comments and Ratings on Marc's Files
Updated File Comment by Comments Rating
16 Jun 2014 SurfaceSmooth Restricted smoothing of a triangulated surface Author: Marc Lalancette Cox, Thomas-Glyn

Nevermind, I figured it out. So far looks great!

Contact us