Assuming that x, f, and d are matrices:
main.m17 chars2 lines
Explanation:
diag(d) returns a square matrix with the elements of d on the diagonal and zeros elsewhere.f and diag(d) will result in an element-wise multiplication of each column of f with the corresponding element of d. The resulting columns are then concatenated to form the matrix x.gistlibby LogSnag