%%
%Author: Fan Jinyang
%Date: 2014/4/21
clear; close all; clc

%define the Matrix Size
MatrixSize = 1000;
out = 0;
A = zeros(MatrixSize);

fprintf('--------------------Start-----------------------------\n');

%Calculate the time of Setting each number of Matrix by row vector
tSetByRowVector = cputime; 
for i = 1 : MatrixSize
    A(i, :) = ones(1, MatrixSize);
end
tSetByRowVector = cputime - tSetByRowVector;
fprintf('Time of Setting by row vector is : %fms.\n', 1000 * tSetByRowVector);

%Calculate the time of Setting each number of Matrix by column vector
tSetByColumnVector = cputime; 
for i = 1 : MatrixSize
    A(: ,i) = ones(MatrixSize, 1);
end
tSetByColumnVector = cputime - tSetByColumnVector;
fprintf('Time of Setting by column vector is : %fms.\n', 1000 * tSetByColumnVector);

%Calculate the time of Setting each number of Matrix by another matrix
B = ones(MatrixSize);
tSetByMatrix = cputime; 
A = B;
tSetByMatrix = cputime - tSetByMatrix;
fprintf('Time of Setting by matrix is : %fms.\n', 1000 * tSetByMatrix);

fprintf('------------------------------------------------------\n');