# MatLab - Raising each component of a matrix

by Aseeb
Tags: component, matlab, matrix, raising
 PF Gold P: 1,160 If you mean raising the each component of the vector to the same power, e.g. you want ##{\boldsymbol x} ^ n = [x_0^n, x_1^n, \ldots, x_m^n]^T##, then you can use: % x = some vector x .^ n; For timing, you can use: t = cputime; % do some operations here elapsed = cputime - t; fprintf('Elasped time: %.2f s\n', elapsed);
 P: 545 MatLab - Raising each component of a matrix For timing, you can also use 'tic' and 'toc' as follows: X = 1:1000; tic X2 = X.^2; toc Elapsed time is 0.006004 seconds. In general, you can put any code snippet between the two tags. 'tic' always marks the beginning of the timer, and 'toc' the end.