Timing in MATLAB

How long does it take to solve a linear system?

Set the size of the system

n = 2000;

Define a random matrix and right-hand side

A = rand(n);
b = rand(n,1);
tic;             % start timer
x = A \ b;       % solve system
tend = toc;      % end timer
fprintf('Time to solve %f seconds.\n', tend)
Time to solve 0.726750 seconds.